-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathgeneratepp.html
More file actions
145 lines (138 loc) · 5.18 KB
/
Copy pathgeneratepp.html
File metadata and controls
145 lines (138 loc) · 5.18 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title id="pageTitle"></title>
<link rel="shortcut icon" href="img/xcpblackyellow.ico">
<link href="settings/styles.css" rel="stylesheet">
<script src="settings/general.txt"></script>
<script src="settings/assets.txt"></script>
<script src="settings/menu.txt"></script>
<script src="settings/encryptedpp.txt"></script>
<script src="drawmenus.js"></script>
<script src="lib/jquery/jquery-2.1.4.js"></script>
<script src="lib/cryptojs v3.1.2/rollups/aes.js"></script>
<script src="lib/cryptojs v3.1.2/rollups/sha256.js"></script>
<script src="lib/seedrandom/seedrandom.min.js"></script>
<script src="lib/bitcore/bitcore.min.js"></script>
<script src="lib/xcp-toolbox/passphrase.js"></script>
<script src="lib/xcp-toolbox/password.js"></script>
<script src="lib/xcp-toolbox/api.js"></script>
<script src="lib/xcp-toolbox/misc.js"></script>
<script src="lib/qrcodejs/qrcode.js"></script>
<script src="lib/chrome-wallet-mod/js/mnemonic.js"></script>
<script src="lib/chrome-wallet-mod/js/xcp-js/pushtx.js"></script>
<script src="lib/chrome-wallet-mod/js/xcp-js/transactions.js"></script>
<script src="lib/chrome-wallet-mod/js/xcp-js/rc4.js"></script>
<script src="lib/chrome-wallet-mod/js/xcp-js/convert-type.js"></script>
<script src="lib/chrome-wallet-mod/js/xcp-js/decode.js"></script>
<script src="lib/chrome-wallet-mod/js/biginteger.js"></script>
<script src="lib/chrome-wallet-mod/js/hex2dec-cs.js"></script>
<script>
//Three entopy sources; Two data generated and one user input
entropyString1 = "";
entropyString2 = "";
entropyString3 = "";
function randomHashInput() {
Math.seedrandom();
var d = new Date();
var n = d.getMilliseconds();
var randstring = d + Math.random() + n + Math.random() + Math.random();
randstring = CryptoJS.SHA256(randstring).toString();
return randstring;
}
function firstEntropy() {
entropyString1 = randomHashInput();
}
function secondEntropy() {
var pwInput = document.getElementById('password').value;
entropyString2 = CryptoJS.SHA256(pwInput).toString();
}
function thirdEntropy() {
entropyString3 = randomHashInput();
}
function validateInputPW() {
var pwInput = document.getElementById('password').value;
var output = "";
var markColor = "";
var score = scorePassword(pwInput);
score *= 1.7;
score = parseInt(score);
if (score > 100) {
score = 100;
}
output = "Strength: " + score + "%";
if (score < 50) {
markColor = "orangered ";
} else if (score < 65) {
markColor = "orange ";
} else if (score < 80) {
markColor = "yellow ";
} else if (score < 100) {
markColor = "greenyellow ";
} else {
markColor = "lime";
}
if (score < 100) {
output = "<mark style=\"background-color:"+markColor+";\">"+output+"</mark>";
} else {
output = "<mark style=\"background-color:"+markColor+";\">Randomness OK</mark>";
}
document.getElementById('pwfeedback').innerHTML = output;
}
function genPP() {
var pwInput = document.getElementById('password').value;
var score = scorePassword(pwInput);
score *= 1.7;
score = parseInt(score);
if (score < 100) {
document.getElementById('newpassphrase').innerHTML = "Please type more random characters.";
return;
}
secondEntropy();
thirdEntropy();
//this will catch some erroneous modifications of the randomness functions
if (entropyString1.length != 64 || entropyString2.length != 64 || entropyString3.length != 64 || entropyString2 == entropyString3) {
document.getElementById('newpassphrase').innerHTML = "Something is wrong! Please use counterwallet.io instead!";
return;
}
var ppNum = [];
for (i = 0; i < 12; i++) {
var noise = entropyString1 + i + entropyString2 + i + entropyString3 + i;
var hash = CryptoJS.SHA256(noise);
Math.seedrandom(hash);
ppNum[i] = Math.floor(Math.random()*1626);
}
var passphrase = ppIntArrayToString(ppNum);
var addresses = genAddr(passphrase, NUM_ADDR_DISPLAY, false);
var output = "";
output += "<br>Your new passphrase is:<br><br>";
output += "<div class=\"boxWarning\">Keep these 12 words secret! If someone gets your passphrase, they gain access to your funds!</div>";
output += "<span class=\"monospaceBold\" style=\"font-size:160%;\">" + passphrase + "</span>";
output += "<br><br>The corresponding addresses are:<span class=\"monospace\"><br>";
for (i = 0; i < addresses.length; i++) {
output += "<br>#" + (i+1) + ": "+ addresses[i][0];
}
output += "</span>";
//output = "<mark style=\"background-color:"+markColor+";\">"+passphrase+"</mark>";
document.getElementById('newpassphrase').innerHTML = output;
}
</script>
</head>
<body onload="drawMenus();firstEntropy();">
<div id="container">
<header id="topHeader"></header>
<nav id="leftMenu"></nav>
<section id="mainSection">
<div class="boxInfo">You do not need to remember the characters you enter.<br><br>In fact, the browser just wants a noisy input to help it generate a truly unpredictable passphrase.</div>
<h1>Generate New Passphrase</h1>
Enter 20+ random characters<br>
<input type="password" onkeyup="validateInputPW()" id="password" placeholder="" style="width:545px;"><br>
<div id="pwfeedback"> </div>
<button onclick="genPP()">Generate Passphrase</button>
<div id="newpassphrase"></div>
</section>
<footer id="bottomFooter"></footer>
</div>
</body>
</html>