mirror of
https://github.com/MrUnknownDE/unknownbin.git
synced 2026-04-18 22:03:44 +02:00
add some fancy magic :kekw:
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
var KeyGenerator = function() {
|
||||
this.keyspace = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
};
|
||||
const crypto = require('crypto');
|
||||
|
||||
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;
|
||||
};
|
||||
class KeyGenerator {
|
||||
constructor() {
|
||||
this.keyspace = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
}
|
||||
|
||||
module.exports = KeyGenerator;
|
||||
createKey(keyLength) {
|
||||
const buffer = crypto.randomBytes(keyLength);
|
||||
let key = '';
|
||||
for (let i = 0; i < buffer.length; i++) {
|
||||
key += this.keyspace.charAt(buffer[i] % this.keyspace.length);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = KeyGenerator;
|
||||
Reference in New Issue
Block a user