|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
var fs = require('fs') |
|
|
|
|
var fs = require('fs'); |
|
|
|
|
|
|
|
|
|
var DictionaryGenerator = function(options) { |
|
|
|
|
//Options
|
|
|
|
@ -9,7 +9,7 @@ var DictionaryGenerator = function(options) { |
|
|
|
|
|
|
|
|
|
//Load dictionary
|
|
|
|
|
fs.readFile(options.path, 'utf8', (err,data) => { |
|
|
|
|
if(err) throw err; |
|
|
|
|
if (err) throw err; |
|
|
|
|
this.dictionary = data.split(/[\n\r]+/); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
@ -18,7 +18,7 @@ var DictionaryGenerator = function(options) { |
|
|
|
|
DictionaryGenerator.prototype.createKey = function(keyLength) { |
|
|
|
|
var text = ''; |
|
|
|
|
for(var i = 0; i < keyLength; i++) |
|
|
|
|
text += this.dictionary[Math.floor(Math.random()*this.dictionary.length)]; |
|
|
|
|
text += this.dictionary[Math.floor(Math.random() * this.dictionary.length)]; |
|
|
|
|
|
|
|
|
|
return text; |
|
|
|
|
}; |
|
|
|
|