mirror of https://github.com/calzoneman/sync.git
20 lines
545 B
JavaScript
20 lines
545 B
JavaScript
module.exports = {
|
|
isValidChannelName: function (name) {
|
|
return name.match(/^[\w-_]{1,30}$/);
|
|
},
|
|
|
|
isValidUserName: function (name) {
|
|
return name.match(/^[\w-_]{1,20}$/);
|
|
},
|
|
|
|
randomSalt: function (length) {
|
|
var chars = "abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
+ "0123456789!@#$%^&*_+=~";
|
|
var salt = [];
|
|
for(var i = 0; i < length; i++) {
|
|
salt.push(chars[parseInt(Math.random()*chars.length)]);
|
|
}
|
|
return salt.join('');
|
|
}
|
|
};
|