mirror of
https://github.com/emn178/js-sha256.git
synced 2026-08-12 20:32:16 +08:00
### 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
25 lines
868 B
JavaScript
25 lines
868 B
JavaScript
(function (Worker, WORKER, SOURCE) {
|
|
var cases = {
|
|
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855': '',
|
|
'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592': 'The quick brown fox jumps over the lazy dog',
|
|
'ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c': 'The quick brown fox jumps over the lazy dog.'
|
|
};
|
|
|
|
describe('#sha256', function () {
|
|
Object.keys(cases).forEach(function (hash) {
|
|
it('should be equal', function (done) {
|
|
var worker = new Worker(WORKER);
|
|
worker.onmessage = function(event) {
|
|
expect(event.data).to.be(hash);
|
|
if (worker.terminate) {
|
|
worker.terminate();
|
|
}
|
|
done();
|
|
};
|
|
worker.postMessage(SOURCE);
|
|
worker.postMessage(cases[hash]);
|
|
});
|
|
});
|
|
});
|
|
})(Worker, WORKER, SOURCE);
|