Skip to content

Commit 9acee69

Browse files
committed
New demo, renamed to index.html
1 parent 5c531f9 commit 9acee69

File tree

3 files changed

+91
-31
lines changed

3 files changed

+91
-31
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ scrypt-async
88

99
Fast "async" scrypt implementation in JavaScript.
1010

11-
Works in browsers without throwing out "kill slow script" warnings due to
12-
configurable interruptStep, which yields from calculation.
13-
14-
Should be compatible even with IE. Also works with Node/io.js (but you should really use the C implementation for that).
11+
Works in browsers without throwing "kill slow script" warnings due to
12+
configurable interruptStep, which yields from calculation. Compatible even with
13+
old versions of IE. Also works with Node/io.js (but you should really use the C
14+
implementation for that).
1515

1616

1717
Installation

demo.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

index.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>scrypt-async-js demo</title>
7+
<style>
8+
html,
9+
body {
10+
font-family: sans-serif;
11+
}
12+
13+
#out {
14+
padding: 10px 0;
15+
}
16+
17+
#N {
18+
margin-left: 10px;
19+
color: #aaa;
20+
}
21+
</style>
22+
</head>
23+
24+
<body>
25+
<h1><a href="https://github.com/dchest/scrypt-async-js">scrypt-async-js</a> demo</h1>
26+
<form onsubmit="calculate(); return false">
27+
<p>Password: <input name="password" type="text" value="password" size="32"></p>
28+
<p>Salt: <input name="salt" type="text" value="salt" size="32"></p>
29+
<p>interruptStep: <input name="interruptStep" type="text" value="0" size="8"></p>
30+
<p>logN: <input name="logN" type="text" value="11" size="4" onkeypress="updateN()"
31+
onchange="updateN()" onkeyup="updateN()"
32+
onblur="updateN()"><span id="N"></p>
33+
<p>r: <input name="r" type="text" value="8" size="4"></p>
34+
<p>p: <input name="p" type="text" value="1" size="4"></p>
35+
<input type="submit" name="btn" value="Calculate" />
36+
</form>
37+
<div id="out"></div>
38+
39+
<script src="scrypt-async.js"></script>
40+
<script>
41+
var f = document.forms[0];
42+
43+
function updateN() {
44+
var fN = document.querySelector('#N');
45+
var logN = f.logN.value;
46+
fN.innerHTML = 'N = ' + Math.pow(2, logN);
47+
}
48+
49+
function calculate() {
50+
51+
var btn = f.btn;
52+
var out = document.querySelector('#out');
53+
54+
var password = f.password.value;
55+
var salt = f.salt.value;
56+
var interruptStep = f.interruptStep.value;
57+
var logN = f.logN.value;
58+
var r = f.r.value;
59+
var p = f.p.value;
60+
61+
btn.disabled = true;
62+
btn.value = 'Wait...';
63+
64+
window.setTimeout(function() {
65+
try {
66+
var t1 = (new Date()).getTime();
67+
scrypt(password, salt, {
68+
logN: logN,
69+
r: r,
70+
p: p,
71+
dkLen: 32,
72+
interruptStep: interruptStep,
73+
encoding: 'hex'
74+
},
75+
function(res) {
76+
var t2 = ((new Date()).getTime()-t1);
77+
out.innerHTML = 'scrypt: <b>'+t2+' ms</b> ' + res + '';
78+
btn.disabled = false;
79+
btn.value = 'Calculate';
80+
});
81+
} catch(ex) {
82+
out.innerHTML = '<span style="color:red">error: ' + ex.message + '</span>'; btn.disabled = false; btn.value = 'Calculate';
83+
} }); } updateN();
84+
</script>
85+
</body>
86+
87+
</html>

0 commit comments

Comments
 (0)