mirror of
https://github.com/MrUnknownDE/unknownbin.git
synced 2026-04-22 07:33:44 +02:00
first push
This commit is contained in:
15
lib/key_generator.js
Normal file
15
lib/key_generator.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var KeyGenerator = function() {
|
||||
this.keyspace = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
};
|
||||
|
||||
KeyGenerator.prototype.createKey = function(keyLength) {
|
||||
var key = '';
|
||||
var index;
|
||||
for (var i = 0; i < keyLength; i++) {
|
||||
index = Math.floor(Math.random() * this.keyspace.length);
|
||||
key += this.keyspace.charAt(index);
|
||||
}
|
||||
return key;
|
||||
};
|
||||
|
||||
module.exports = KeyGenerator;
|
||||
Reference in New Issue
Block a user