mirror of
https://github.com/MrUnknownDE/unknownbin.git
synced 2026-04-13 03:23:44 +02:00
16 lines
391 B
JavaScript
16 lines
391 B
JavaScript
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;
|