Skip to content

Commit bf1b729

Browse files
committed
Removed setting global Buffer (to ensure no Buffer dependency).
1 parent 50a1f85 commit bf1b729

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

index.html

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
input[type=submit]:active {
6363
background-color: #cfc;
6464
color: #040;
65-
6665
}
6766

6867
input[type=submit].cancel {
@@ -72,9 +71,8 @@
7271
input[type=submit]:active.cancel {
7372
background-color: #fcc;
7473
color: #400;
75-
7674
}
77-
75+
7876
input {
7977
margin-bottom: 30px;
8078
}
@@ -107,7 +105,7 @@
107105
position: relative;
108106
width: 100%;
109107
}
110-
108+
111109
#progressBar {
112110
background: #ccf;
113111
border-radius: 15px;
@@ -136,10 +134,10 @@ <h1>scrypt-js</h1>
136134
<div>
137135
<div><b>Password</b> <span id="form-password" class="forms"><a class="form selected">UTF-8 (NFKC)</a><b>&bull;</b><a class="form">UTF-8 (NFKD)</a><b>&bull;</b><a class="form">hex</a></span></div>
138136
<input id="pbkdf-password" type="text" value="password" />
139-
137+
140138
<div><b>Salt</b> <span id="form-salt" class="forms"><a class="form selected">UTF-8 (NFKC)</a><b>&bull;</b><a class="form">UTF-8 (NFKD)</a><b>&bull;</b><a class="form">hex</a></span></div>
141139
<input id="pbkdf-salt" type="text" value="salt" />
142-
140+
143141
<div class="clearfix"></div>
144142
<div>
145143
<div class="param">
@@ -162,7 +160,7 @@ <h1>scrypt-js</h1>
162160
<div class="clearfix"></div>
163161
<input id="pbkdf-submit" type="submit" value="Compute scrypt" />
164162
<div class="progress"><div id="progressBar"></div><div id="progressAmount">0%</div></div>
165-
<div id="result"></div>
163+
<div id="result"></div>
166164
</div>
167165
</div>
168166
</div>
@@ -173,7 +171,6 @@ <h1>scrypt-js</h1>
173171
<script src="scrypt.js" type="text/javascript"></script>
174172

175173
<script type="text/javascript">
176-
window.Buffer = buffer.SlowBuffer;
177174

178175
function get(id) { return document.getElementById(id); }
179176
function normalized(field) {
@@ -183,14 +180,14 @@ <h1>scrypt-js</h1>
183180
var form = forms[0].innerHTML;
184181

185182
if (form.indexOf('NFKC') >= 0) {
186-
return new Buffer(value.normalize('NFKC'), 'utf8');
183+
return new buffer.SlowBuffer(value.normalize('NFKC'), 'utf8');
187184
} else if (form.indexOf('NFKD') >= 0) {
188-
return new Buffer(value.normalize('NFKD'), 'utf8');
185+
return new buffer.SlowBuffer(value.normalize('NFKD'), 'utf8');
189186
} else if (form.indexOf('hex') >= 0) {
190187
if (!value.match(/^[0-9A-F][0-9A-F]$/i)) {
191188
throw new Error(field + ': invalid hex string');
192189
}
193-
return new Buffer(value, 'hex');
190+
return new buffer.SlowBuffer(value, 'hex');
194191
}
195192

196193
throw new Error('Unknown ');
@@ -238,11 +235,11 @@ <h1>scrypt-js</h1>
238235
var r = get('pbkdf-r').value;
239236
var p = get('pbkdf-p').value;
240237
var dkLen = get('pbkdf-dkLen').value;
241-
console.log(password, salt)
238+
console.log(password, salt, N, r, p)
242239

243240
} catch (error) {
244241
printConsole(error.message);
245-
242+
246243
done = null;
247244
return;
248245
}
@@ -260,7 +257,7 @@ <h1>scrypt-js</h1>
260257
printConsole("Cancelled: " + parseInt(100 * progress) + "% done");
261258

262259
} else if (key) {
263-
key = new Buffer(key);
260+
key = new buffer.SlowBuffer(key);
264261
printConsole("Generated: " + key.toString('hex'));
265262
printConsole("Complete: " + (((new Date()).getTime() - t0) / 1000) + 's');
266263
}
@@ -274,8 +271,8 @@ <h1>scrypt-js</h1>
274271

275272
} else if (done) {
276273
return true;
277-
}
278-
274+
}
275+
279276
get('progressBar').style.width = parseInt(100 * progress) + '%';
280277
get('progressAmount').innerHTML = parseInt(100 * progress) + '%';
281278
});

0 commit comments

Comments
 (0)