mirror of
https://github.com/seejohnrun/haste-server.git
synced 2025-12-13 06:05:55 +00:00
14
lib/key_generators/random.js
Normal file
14
lib/key_generators/random.js
Normal file
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user