ButlerBin/lib/key_generator.js
Jack Hadrill eba23bd088
All checks were successful
TerribleCodeClub/ButlerBin/pipeline/head This commit looks good
Simplify for Butlersaurus
2020-06-08 22:46:43 +01:00

21 lines
476 B
JavaScript

module.exports = class KeyGenerator {
// Initialize a new generator with the given keySpace
constructor() {
this.keyspace = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
}
// Generate a key of the given length
createKey(keyLength) {
var text = '';
for (var i = 0; i < keyLength; i++) {
const index = Math.floor(Math.random() * this.keyspace.length);
text += this.keyspace.charAt(index);
}
return text;
}
};