Last active
January 18, 2019 08:29
-
-
Save xmichaelx/e5be1b07c1a4d9e0059d7dbcde3f37a2 to your computer and use it in GitHub Desktop.
password generation based on https://www.eff.org/dice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
function getDictionary() { | |
var wordDictionary = {}; | |
document.getElementById("wordlist").value.trim().split("\n").forEach(line => { | |
var tokens = line.split("\t"); | |
wordDictionary[tokens[0]] = tokens[1]; | |
}); | |
return wordDictionary; | |
} | |
function randomNumber() { | |
var buffer = new Uint8Array(1); | |
while ((buffer[0] < 1) || (buffer[0] > 6)) | |
crypto.getRandomValues(buffer); // cryptographically random values | |
return buffer[0]; | |
} | |
function randomNumberString() { | |
var word = ""; | |
for (var i = 0; i< 5;i ++) word += randomNumber(); | |
return word; | |
} | |
function generate() { | |
var wordCount = parseInt(document.getElementById("wordsToGenerate").value); | |
var wordDictionary = getDictionary(); | |
var list = []; | |
for (var i = 0; i<wordCount;i++) { | |
var word = randomNumberString(); | |
list.push(wordDictionary[word]); | |
} | |
document.getElementById("result").cols = list.join("").length; | |
document.getElementById("result").value = list.join(""); | |
} | |
</script> | |
</head> | |
<body> | |
Copy wordlist from <a href="https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt">EFF large wordlist</a> and paste here: <br/> | |
<textarea id="wordlist"></textarea><br/> | |
Number of words to generate:<br/> | |
<input id="wordsToGenerate" type="number" value="5" /><br/> | |
<button onclick="generate();">Generate</button><br/> | |
<textarea id="result" ></textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment