1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 11:31:22 +00:00
haste-server/lib/key_generators/random.js
2012-01-07 11:35:11 -05:00

14 lines
442 B
JavaScript

var RandomKeyGenerator = function(options) {
this.keyspace = options.keyspace || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
};
// Generate a random key
RandomKeyGenerator.prototype.createKey = function(keyLength) {
var text = '';
for (var i = 0; i < keyLength; i++) {
text += this.keyspace.charAt(Math.floor(Math.random() * this.keyspace.length));
}
return text;
};
module.exports = RandomKeyGenerator;