mirror of
https://github.com/emn178/js-sha256.git
synced 2026-08-13 04:51:56 +08:00
## v0.10.0 / 2023-08-30
### Fixed - Chrome bug by workaround. #40 - deprecated `new Buffer`, replace with `Buffer.from`. #34 - dependencies and security issues. #32, #36 ### Changed - TypeScript interface, secretKey can be bytes like message. #23, #25 - remove `eval` and use `require` directly. #18, #26
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v0.10.0 / 2023-08-30
|
||||||
|
### Fixed
|
||||||
|
- Chrome bug by workaround. #40
|
||||||
|
- deprecated `new Buffer`, replace with `Buffer.from`. #34
|
||||||
|
- dependencies and security issues. #32, #36
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- TypeScript interface, secretKey can be bytes like message. #23, #25
|
||||||
|
- remove `eval` and use `require` directly. #18, #26
|
||||||
|
|
||||||
## v0.9.0 / 2017-12-18
|
## v0.9.0 / 2017-12-18
|
||||||
### Fixed
|
### Fixed
|
||||||
- incorrect result when first bit is 1 of bytes.
|
- incorrect result when first bit is 1 of bytes.
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ var hash2 = sha256.hmac.update('key', 'Message to hash');
|
|||||||
hash2.update('Message2 to hash');
|
hash2.update('Message2 to hash');
|
||||||
hash2.array();
|
hash2.array();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Node.js
|
||||||
If you use node.js, you should require the module first:
|
If you use node.js, you should require the module first:
|
||||||
```JavaScript
|
```JavaScript
|
||||||
var sha256 = require('js-sha256');
|
var sha256 = require('js-sha256');
|
||||||
@@ -57,16 +59,22 @@ or
|
|||||||
var sha256 = require('js-sha256').sha256;
|
var sha256 = require('js-sha256').sha256;
|
||||||
var sha224 = require('js-sha256').sha224;
|
var sha224 = require('js-sha256').sha224;
|
||||||
```
|
```
|
||||||
|
or
|
||||||
|
```JavaScript
|
||||||
|
const { sha256, sha224 } = require('js-sha256');
|
||||||
|
```
|
||||||
|
### TypeScript
|
||||||
|
or TypeScript
|
||||||
|
```TypeScript
|
||||||
|
import { sha256, sha224 } from 'js-sha256';
|
||||||
|
```
|
||||||
|
### RequireJS
|
||||||
It supports AMD:
|
It supports AMD:
|
||||||
```JavaScript
|
```JavaScript
|
||||||
require(['your/path/sha256.js'], function(sha256) {
|
require(['your/path/sha256.js'], function(sha256) {
|
||||||
// ...
|
// ...
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
or TypeScript
|
|
||||||
```TypeScript
|
|
||||||
import { sha256, sha224 } from 'js-sha256';
|
|
||||||
```
|
|
||||||
## Example
|
## Example
|
||||||
```JavaScript
|
```JavaScript
|
||||||
sha256(''); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
sha256(''); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||||
|
|||||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+7
-7
@@ -41,14 +41,14 @@ interface Hmac {
|
|||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
(secretKey: string, message: Message): string;
|
(secretKey: Message, message: Message): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a hash object using a secret key.
|
* Create a hash object using a secret key.
|
||||||
*
|
*
|
||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
*/
|
*/
|
||||||
create(secretKey: string): Hasher;
|
create(secretKey: Message): Hasher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a hash object and hash message using a secret key
|
* Create a hash object and hash message using a secret key
|
||||||
@@ -56,7 +56,7 @@ interface Hmac {
|
|||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
update(secretKey: string, message: Message): Hasher;
|
update(secretKey: Message, message: Message): Hasher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return hash in hex string.
|
* Return hash in hex string.
|
||||||
@@ -64,7 +64,7 @@ interface Hmac {
|
|||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
hex(secretKey: string, message: Message): string;
|
hex(secretKey: Message, message: Message): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return hash in ArrayBuffer.
|
* Return hash in ArrayBuffer.
|
||||||
@@ -72,7 +72,7 @@ interface Hmac {
|
|||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
arrayBuffer(secretKey: string, message: Message): ArrayBuffer;
|
arrayBuffer(secretKey: Message, message: Message): ArrayBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return hash in integer array.
|
* Return hash in integer array.
|
||||||
@@ -80,7 +80,7 @@ interface Hmac {
|
|||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
digest(secretKey: string, message: Message): number[];
|
digest(secretKey: Message, message: Message): number[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return hash in integer array.
|
* Return hash in integer array.
|
||||||
@@ -88,7 +88,7 @@ interface Hmac {
|
|||||||
* @param secretKey The Secret Key
|
* @param secretKey The Secret Key
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
array(secretKey: string, message: Message): number[];
|
array(secretKey: Message, message: Message): number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Hash {
|
interface Hash {
|
||||||
|
|||||||
Generated
+20
-27
@@ -497,12 +497,6 @@
|
|||||||
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"bindings": {
|
|
||||||
"version": "1.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
|
|
||||||
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
@@ -730,6 +724,12 @@
|
|||||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"esm": {
|
||||||
|
"version": "3.2.25",
|
||||||
|
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
|
||||||
|
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"esprima": {
|
"esprima": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||||
@@ -1208,12 +1208,6 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"nan": {
|
|
||||||
"version": "2.8.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz",
|
|
||||||
"integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"nanoid": {
|
"nanoid": {
|
||||||
"version": "3.3.3",
|
"version": "3.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz",
|
||||||
@@ -1586,9 +1580,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"serialize-javascript": {
|
"serialize-javascript": {
|
||||||
@@ -1716,6 +1710,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tiny-worker": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tiny-worker/-/tiny-worker-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"esm": "^3.2.25"
|
||||||
|
}
|
||||||
|
},
|
||||||
"to-fast-properties": {
|
"to-fast-properties": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||||
@@ -1752,8 +1755,8 @@
|
|||||||
"integrity": "sha512-ari2E89bD7f+fMU173NgF12JBcOhgoxeyuCs97h5K58IBENrnG9eVj2lFadrOPdqf0KifsxVmUQfzA2cHNxCZQ==",
|
"integrity": "sha512-ari2E89bD7f+fMU173NgF12JBcOhgoxeyuCs97h5K58IBENrnG9eVj2lFadrOPdqf0KifsxVmUQfzA2cHNxCZQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"commander": "2.11.0",
|
"commander": "~2.11.0",
|
||||||
"source-map": "0.6.1"
|
"source-map": "~0.6.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": {
|
"commander": {
|
||||||
@@ -1780,16 +1783,6 @@
|
|||||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"webworker-threads": {
|
|
||||||
"version": "0.7.13",
|
|
||||||
"resolved": "https://registry.npmjs.org/webworker-threads/-/webworker-threads-0.7.13.tgz",
|
|
||||||
"integrity": "sha1-yEsYtrokElu503NC5E3rgVFi+4M=",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"bindings": "1.3.0",
|
|
||||||
"nan": "2.8.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"which": {
|
"which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
|||||||
+3
-3
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "js-sha256",
|
"name": "js-sha256",
|
||||||
"version": "0.9.0",
|
"version": "0.10.0",
|
||||||
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
|
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
|
||||||
"main": "src/sha256.js",
|
"main": "src/sha256.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"expect.js": "~0.3.1",
|
"expect.js": "~0.3.1",
|
||||||
"mocha": "~10.2.0",
|
"mocha": "~10.2.0",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"uglify-js": "^3.1.9",
|
"tiny-worker": "^2.3.0",
|
||||||
"webworker-threads": "^0.7.13"
|
"uglify-js": "^3.1.9"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "nyc mocha tests/node-test.js",
|
"test": "nyc mocha tests/node-test.js",
|
||||||
|
|||||||
+14
-5
@@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
||||||
*
|
*
|
||||||
* @version 0.9.0
|
* @version 0.10.0
|
||||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* @copyright Chen, Yi-Cyuan 2014-2017
|
* @copyright Chen, Yi-Cyuan 2014-2023
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
/*jslint bitwise: true */
|
/*jslint bitwise: true */
|
||||||
@@ -80,9 +80,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var nodeWrap = function (method, is224) {
|
var nodeWrap = function (method, is224) {
|
||||||
var crypto = eval("require('crypto')");
|
var crypto = require('crypto')
|
||||||
var Buffer = eval("require('buffer').Buffer");
|
var Buffer = require('buffer').Buffer;
|
||||||
var algorithm = is224 ? 'sha224' : 'sha256';
|
var algorithm = is224 ? 'sha224' : 'sha256';
|
||||||
|
var bufferFrom;
|
||||||
|
if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
||||||
|
bufferFrom = Buffer.from;
|
||||||
|
} else {
|
||||||
|
bufferFrom = function (message) {
|
||||||
|
return new Buffer(message);
|
||||||
|
};
|
||||||
|
}
|
||||||
var nodeMethod = function (message) {
|
var nodeMethod = function (message) {
|
||||||
if (typeof message === 'string') {
|
if (typeof message === 'string') {
|
||||||
return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
|
return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
|
||||||
@@ -95,7 +103,7 @@
|
|||||||
}
|
}
|
||||||
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
||||||
message.constructor === Buffer) {
|
message.constructor === Buffer) {
|
||||||
return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex');
|
return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex');
|
||||||
} else {
|
} else {
|
||||||
return method(message);
|
return method(message);
|
||||||
}
|
}
|
||||||
@@ -328,6 +336,7 @@
|
|||||||
t2 = s0 + maj;
|
t2 = s0 + maj;
|
||||||
e = a + t1 << 0;
|
e = a + t1 << 0;
|
||||||
a = t1 + t2 << 0;
|
a = t1 + t2 << 0;
|
||||||
|
this.chromeBugWorkAround = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.h0 = this.h0 + a << 0;
|
this.h0 = this.h0 + a << 0;
|
||||||
|
|||||||
+5
-1
@@ -1,5 +1,5 @@
|
|||||||
expect = require('expect.js');
|
expect = require('expect.js');
|
||||||
Worker = require('webworker-threads').Worker;
|
Worker = require("tiny-worker");
|
||||||
|
|
||||||
function unset() {
|
function unset() {
|
||||||
delete require.cache[require.resolve('../src/sha256.js')];
|
delete require.cache[require.resolve('../src/sha256.js')];
|
||||||
@@ -40,6 +40,10 @@ function runWindowTest() {
|
|||||||
BUFFER = true;
|
BUFFER = true;
|
||||||
runCommonJsTest();
|
runCommonJsTest();
|
||||||
|
|
||||||
|
// Node.js env, no Buffer.from
|
||||||
|
JS_SHA256_NO_BUFFER_FROM = true
|
||||||
|
runCommonJsTest();
|
||||||
|
|
||||||
// Webpack browser env
|
// Webpack browser env
|
||||||
JS_SHA256_NO_NODE_JS = true;
|
JS_SHA256_NO_NODE_JS = true;
|
||||||
window = global;
|
window = global;
|
||||||
|
|||||||
+4
-4
@@ -102,12 +102,12 @@
|
|||||||
|
|
||||||
if (typeof BUFFER === 'boolean' && BUFFER) {
|
if (typeof BUFFER === 'boolean' && BUFFER) {
|
||||||
testCases.sha256.Buffer = {
|
testCases.sha256.Buffer = {
|
||||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855': new Buffer(0),
|
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855': Buffer.from([]),
|
||||||
'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592': new Buffer(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592': Buffer.from(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
||||||
};
|
};
|
||||||
testCases.sha224.Buffer = {
|
testCases.sha224.Buffer = {
|
||||||
'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f': new Buffer(0),
|
'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f': Buffer.from([]),
|
||||||
'730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525': new Buffer(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
'730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525': Buffer.from(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
var worker = new Worker(WORKER);
|
var worker = new Worker(WORKER);
|
||||||
worker.onmessage = function(event) {
|
worker.onmessage = function(event) {
|
||||||
expect(event.data).to.be(hash);
|
expect(event.data).to.be(hash);
|
||||||
|
if (worker.terminate) {
|
||||||
|
worker.terminate();
|
||||||
|
}
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
worker.postMessage(SOURCE);
|
worker.postMessage(SOURCE);
|
||||||
|
|||||||
+3
-3
@@ -3,9 +3,9 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>SHA256</title>
|
<title>SHA256</title>
|
||||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.css">
|
||||||
<script src="../node_modules/mocha/mocha.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
|
||||||
<script src="../node_modules/expect.js/index.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect.js/0.2.0/expect.min.js"></script>
|
||||||
<script src="../src/sha256.js"></script>
|
<script src="../src/sha256.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user