add some fancy magic :kekw:

This commit is contained in:
2025-10-13 18:21:23 +02:00
parent 2e59c1f5e7
commit 22badaf535
15 changed files with 1328 additions and 786 deletions

View File

@@ -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;