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