-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiceware.html
102 lines (87 loc) · 3.57 KB
/
diceware.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<html>
<head>
<title>Diceware Random Passphrase Generator</title>
<script src="dicewareEFF.js"></script>
<style>
#passPhrase {
font: 3em arial, sans-serif;
}
p {
width: 525px;
font: .75em arial, sans-serif;
}
</style>
</head>
<body onload="generatePassPhrase(5);">
<select id="numWords" onChange="generatePassPhrase()">
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<!--- Placeholder for passphrase --->
<div id="passPhrase"></div>
<!--- License and Attribution --->
<p>
Diceware<br>
<a href="http://world.std.com/~reinhold/diceware.html">http://world.std.com/~reinhold/diceware.html</a>
<br><br>
Copyright © 1995-2016, Arnold G. Reinhold, Cambridge, Massachusetts USA.
<br><br>
The author hereby grants rights for free, non-commercial, electronic distribution, with attribution, of this entire text. Linking to this page or the word list, including for commercial use, is permitted and encouraged. All other rights reserved. Reasonable requests for other uses, such as translations, are encouraged and will be carefully and promptly considered. This information is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
<br><br>
To the extent that a word list is protected by copyright, A G Reinhold licenses its rights to the English Diceware Wordlist under the Creative Commons CC-BY 3.0 license.
<br>
<a href="http://creativecommons.org/licenses/by/3.0/">http://creativecommons.org/licenses/by/3.0/</a>
<br><br>
Diceware is a trademark of A G Reinhold.
<br><br>
First published on usenet's sci.crypt.research 1995-8-1
<br><br>
Alternate word list provided by EFF
<br>
<a href="https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases">https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases</a>
</p>
</body>
<script>
function el(s) {
return document.getElementById(s);
}
// convert words to Title Case
function toTitleCase(s) {
var arr = s.split("");
arr[0] = arr[0].toUpperCase();
s = arr.join("");
//console.log (s);
return s;
}
var passPhrase = "";
var words = 5;
function generatePassPhrase(words){
//if words isn't passed in, use 5 as the default number
if (words === undefined)
words = 5;
// limit words to 10;
if (words > 10)
words = 10;
// create 32byte seed
var array = new Uint32Array(words);
for (i=0; i<words; i++){
// translate seed to faction
var seed = '0.' + window.crypto.getRandomValues(array)[i];
// use seed to get random diceware word
var rndNum = Math.floor((seed * diceware.length) + 1);
// add space between words
passPhrase += (i == 0 ? "" : " ") + toTitleCase(diceware[rndNum].word);
// view raw data in browser console
// create console header
if (i == 0 ) console.log ("index :: (dice roll) word\n=========================");
console.log (rndNum + " :: " + "(" + diceware[rndNum].id + ") " + diceware[rndNum].word);
}
// display passphrase
el("passPhrase").innerHTML = passPhrase;
}
</script>
</html>