mirror of
https://github.com/emn178/js-sha3.git
synced 2026-08-13 03:51:54 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d6193d7f2 | ||
|
|
8ae70989ae | ||
|
|
035642212a | ||
|
|
9f8c2a3fb3 | ||
|
|
ec2a9948f9 | ||
|
|
f34e33dc99 |
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
|
/node_modules/
|
||||||
/tests/
|
/tests/
|
||||||
node_modules/
|
|
||||||
|
|||||||
+3
-3
@@ -1,3 +1,3 @@
|
|||||||
node_modules/
|
/node_modules/
|
||||||
covreporter
|
/covreporter/
|
||||||
my_test
|
/my_test/
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
my_test
|
|
||||||
covreporter
|
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v0.5.7 / 2016-12-30
|
||||||
|
### Fixed
|
||||||
|
- ArrayBuffer detection in old browsers.
|
||||||
|
|
||||||
|
## v0.5.6 / 2016-12-29
|
||||||
|
### Fixed
|
||||||
|
- ArrayBuffer dosen't work in Webpack.
|
||||||
|
|
||||||
## v0.5.5 / 2016-09-26
|
## v0.5.5 / 2016-09-26
|
||||||
### Added
|
### Added
|
||||||
- TypeScript support.
|
- TypeScript support.
|
||||||
|
|||||||
@@ -85,6 +85,10 @@ keccak_224 = require('js-sha3').keccak_224;
|
|||||||
shake_128 = require('js-sha3').shake_128;
|
shake_128 = require('js-sha3').shake_128;
|
||||||
shake_256 = require('js-sha3').shake_256;
|
shake_256 = require('js-sha3').shake_256;
|
||||||
```
|
```
|
||||||
|
If you use TypeScript, you can import like this:
|
||||||
|
```TypeScript
|
||||||
|
import { sha3_512 } from 'js-sha3';
|
||||||
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
Code
|
Code
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "js-sha3",
|
"name": "js-sha3",
|
||||||
"version": "0.5.5",
|
"version": "0.5.7",
|
||||||
"main": ["src/sha3.js"],
|
"main": ["src/sha3.js"],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"samples",
|
"samples",
|
||||||
|
|||||||
Vendored
+2
-15
File diff suppressed because one or more lines are too long
+7
-3
@@ -1,17 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "js-sha3",
|
"name": "js-sha3",
|
||||||
"version": "0.5.5",
|
"version": "0.5.7",
|
||||||
"description": "A simple SHA-3 / Keccak / Shake hash function for JavaScript supports UTF-8 encoding.",
|
"description": "A simple SHA-3 / Keccak / Shake hash function for JavaScript supports UTF-8 encoding.",
|
||||||
"main": "src/sha3.js",
|
"main": "src/sha3.js",
|
||||||
"typings": "index",
|
"typings": "index",
|
||||||
|
"types": "index.d.ts",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"expect.js": "~0.3.1",
|
"expect.js": "~0.3.1",
|
||||||
"jscoverage": "~0.5.9",
|
"jscoverage": "~0.5.9",
|
||||||
"mocha": "~2.3.2"
|
"mocha": "~2.3.2",
|
||||||
|
"uglifyjs": "~2.4.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha tests/node-test.js -r jscoverage",
|
"test": "mocha tests/node-test.js -r jscoverage",
|
||||||
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls"
|
"report": "mocha tests/node-test.js -r jscoverage --covout=html",
|
||||||
|
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls",
|
||||||
|
"build": "uglifyjs src/sha3.js --compress --mangle --comments --output build/sha3.min.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
+40
-36
@@ -1,19 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
||||||
*
|
*
|
||||||
* @version 0.5.5
|
* @version 0.5.7
|
||||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* @copyright Chen, Yi-Cyuan 2015-2016
|
* @copyright Chen, Yi-Cyuan 2015-2016
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
(function (root) {
|
/*jslint bitwise: true */
|
||||||
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
|
var root = typeof window === 'object' ? window : {};
|
||||||
|
var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
||||||
if (NODE_JS) {
|
if (NODE_JS) {
|
||||||
root = global;
|
root = global;
|
||||||
}
|
}
|
||||||
var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;
|
var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports;
|
||||||
var HEX_CHARS = '0123456789abcdef'.split('');
|
var HEX_CHARS = '0123456789abcdef'.split('');
|
||||||
var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
|
var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
|
||||||
var KECCAK_PADDING = [1, 256, 65536, 16777216];
|
var KECCAK_PADDING = [1, 256, 65536, 16777216];
|
||||||
@@ -31,13 +33,13 @@
|
|||||||
var createOutputMethod = function (bits, padding, outputType) {
|
var createOutputMethod = function (bits, padding, outputType) {
|
||||||
return function (message) {
|
return function (message) {
|
||||||
return new Keccak(bits, padding, bits).update(message)[outputType]();
|
return new Keccak(bits, padding, bits).update(message)[outputType]();
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var createShakeOutputMethod = function (bits, padding, outputType) {
|
var createShakeOutputMethod = function (bits, padding, outputType) {
|
||||||
return function (message, outputBits) {
|
return function (message, outputBits) {
|
||||||
return new Keccak(bits, padding, outputBits).update(message)[outputType]();
|
return new Keccak(bits, padding, outputBits).update(message)[outputType]();
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var createMethod = function (bits, padding) {
|
var createMethod = function (bits, padding) {
|
||||||
@@ -48,7 +50,7 @@
|
|||||||
method.update = function (message) {
|
method.update = function (message) {
|
||||||
return method.create().update(message);
|
return method.create().update(message);
|
||||||
};
|
};
|
||||||
for (var i = 0;i < OUTPUT_TYPES.length;++i) {
|
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
||||||
var type = OUTPUT_TYPES[i];
|
var type = OUTPUT_TYPES[i];
|
||||||
method[type] = createOutputMethod(bits, padding, type);
|
method[type] = createOutputMethod(bits, padding, type);
|
||||||
}
|
}
|
||||||
@@ -63,7 +65,7 @@
|
|||||||
method.update = function (message, outputBits) {
|
method.update = function (message, outputBits) {
|
||||||
return method.create(outputBits).update(message);
|
return method.create(outputBits).update(message);
|
||||||
};
|
};
|
||||||
for (var i = 0;i < OUTPUT_TYPES.length;++i) {
|
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
||||||
var type = OUTPUT_TYPES[i];
|
var type = OUTPUT_TYPES[i];
|
||||||
method[type] = createShakeOutputMethod(bits, padding, type);
|
method[type] = createShakeOutputMethod(bits, padding, type);
|
||||||
}
|
}
|
||||||
@@ -76,13 +78,15 @@
|
|||||||
{name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}
|
{name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}
|
||||||
];
|
];
|
||||||
|
|
||||||
var methods = {};
|
var methods = {}, methodNames = [];
|
||||||
|
|
||||||
for (var i = 0;i < algorithms.length;++i) {
|
for (var i = 0; i < algorithms.length; ++i) {
|
||||||
var algorithm = algorithms[i];
|
var algorithm = algorithms[i];
|
||||||
var bits = algorithm.bits;
|
var bits = algorithm.bits;
|
||||||
for (var j = 0;j < bits.length;++j) {
|
for (var j = 0; j < bits.length; ++j) {
|
||||||
methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);
|
var methodName = algorithm.name +'_' + bits[j];
|
||||||
|
methodNames.push(methodName);
|
||||||
|
methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,33 +103,33 @@
|
|||||||
this.outputBlocks = outputBits >> 5;
|
this.outputBlocks = outputBits >> 5;
|
||||||
this.extraBytes = (outputBits & 31) >> 3;
|
this.extraBytes = (outputBits & 31) >> 3;
|
||||||
|
|
||||||
for (var i = 0;i < 50;++i) {
|
for (var i = 0; i < 50; ++i) {
|
||||||
this.s[i] = 0;
|
this.s[i] = 0;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Keccak.prototype.update = function (message) {
|
Keccak.prototype.update = function (message) {
|
||||||
var notString = typeof message != 'string';
|
var notString = typeof message !== 'string';
|
||||||
if (notString && message.constructor == root.ArrayBuffer) {
|
if (notString && message.constructor === ArrayBuffer) {
|
||||||
message = new Uint8Array(message);
|
message = new Uint8Array(message);
|
||||||
}
|
}
|
||||||
var length = message.length, blocks = this.blocks, byteCount = this.byteCount,
|
var length = message.length, blocks = this.blocks, byteCount = this.byteCount,
|
||||||
blockCount = this.blockCount, index = 0, s = this.s, i, code;
|
blockCount = this.blockCount, index = 0, s = this.s, i, code;
|
||||||
|
|
||||||
while (index < length) {
|
while (index < length) {
|
||||||
if (this.reset) {
|
if (this.reset) {
|
||||||
this.reset = false;
|
this.reset = false;
|
||||||
blocks[0] = this.block;
|
blocks[0] = this.block;
|
||||||
for (i = 1;i < blockCount + 1;++i) {
|
for (i = 1; i < blockCount + 1; ++i) {
|
||||||
blocks[i] = 0;
|
blocks[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notString) {
|
if (notString) {
|
||||||
for (i = this.start;index < length && i < byteCount;++index) {
|
for (i = this.start; index < length && i < byteCount; ++index) {
|
||||||
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = this.start;index < length && i < byteCount;++index) {
|
for (i = this.start; index < length && i < byteCount; ++index) {
|
||||||
code = message.charCodeAt(index);
|
code = message.charCodeAt(index);
|
||||||
if (code < 0x80) {
|
if (code < 0x80) {
|
||||||
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
||||||
@@ -149,7 +153,7 @@
|
|||||||
if (i >= byteCount) {
|
if (i >= byteCount) {
|
||||||
this.start = i - byteCount;
|
this.start = i - byteCount;
|
||||||
this.block = blocks[blockCount];
|
this.block = blocks[blockCount];
|
||||||
for (i = 0;i < blockCount;++i) {
|
for (i = 0; i < blockCount; ++i) {
|
||||||
s[i] ^= blocks[i];
|
s[i] ^= blocks[i];
|
||||||
}
|
}
|
||||||
f(s);
|
f(s);
|
||||||
@@ -164,14 +168,14 @@
|
|||||||
Keccak.prototype.finalize = function () {
|
Keccak.prototype.finalize = function () {
|
||||||
var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
|
var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
|
||||||
blocks[i >> 2] |= this.padding[i & 3];
|
blocks[i >> 2] |= this.padding[i & 3];
|
||||||
if (this.lastByteIndex == this.byteCount) {
|
if (this.lastByteIndex === this.byteCount) {
|
||||||
blocks[0] = blocks[blockCount];
|
blocks[0] = blocks[blockCount];
|
||||||
for (i = 1;i < blockCount + 1;++i) {
|
for (i = 1; i < blockCount + 1; ++i) {
|
||||||
blocks[i] = 0;
|
blocks[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blocks[blockCount - 1] |= 0x80000000;
|
blocks[blockCount - 1] |= 0x80000000;
|
||||||
for (i = 0;i < blockCount;++i) {
|
for (i = 0; i < blockCount; ++i) {
|
||||||
s[i] ^= blocks[i];
|
s[i] ^= blocks[i];
|
||||||
}
|
}
|
||||||
f(s);
|
f(s);
|
||||||
@@ -184,14 +188,14 @@
|
|||||||
extraBytes = this.extraBytes, i = 0, j = 0;
|
extraBytes = this.extraBytes, i = 0, j = 0;
|
||||||
var hex = '', block;
|
var hex = '', block;
|
||||||
while (j < outputBlocks) {
|
while (j < outputBlocks) {
|
||||||
for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
|
for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
|
||||||
block = s[i];
|
block = s[i];
|
||||||
hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
|
hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
|
||||||
HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
|
HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
|
||||||
HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
|
HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
|
||||||
HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
|
HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
|
||||||
}
|
}
|
||||||
if (j % blockCount == 0) {
|
if (j % blockCount === 0) {
|
||||||
f(s);
|
f(s);
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
@@ -225,10 +229,10 @@
|
|||||||
}
|
}
|
||||||
var array = new Uint32Array(buffer);
|
var array = new Uint32Array(buffer);
|
||||||
while (j < outputBlocks) {
|
while (j < outputBlocks) {
|
||||||
for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
|
for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
|
||||||
array[j] = s[i];
|
array[j] = s[i];
|
||||||
}
|
}
|
||||||
if (j % blockCount == 0) {
|
if (j % blockCount === 0) {
|
||||||
f(s);
|
f(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,7 +252,7 @@
|
|||||||
extraBytes = this.extraBytes, i = 0, j = 0;
|
extraBytes = this.extraBytes, i = 0, j = 0;
|
||||||
var array = [], offset, block;
|
var array = [], offset, block;
|
||||||
while (j < outputBlocks) {
|
while (j < outputBlocks) {
|
||||||
for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {
|
for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
|
||||||
offset = j << 2;
|
offset = j << 2;
|
||||||
block = s[i];
|
block = s[i];
|
||||||
array[offset] = block & 0xFF;
|
array[offset] = block & 0xFF;
|
||||||
@@ -256,7 +260,7 @@
|
|||||||
array[offset + 2] = (block >> 16) & 0xFF;
|
array[offset + 2] = (block >> 16) & 0xFF;
|
||||||
array[offset + 3] = (block >> 24) & 0xFF;
|
array[offset + 3] = (block >> 24) & 0xFF;
|
||||||
}
|
}
|
||||||
if (j % blockCount == 0) {
|
if (j % blockCount === 0) {
|
||||||
f(s);
|
f(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +285,7 @@
|
|||||||
b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
|
b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
|
||||||
b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
|
b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
|
||||||
b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
|
b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
|
||||||
for (n = 0;n < 48;n += 2) {
|
for (n = 0; n < 48; n += 2) {
|
||||||
c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
|
c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
|
||||||
c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
|
c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
|
||||||
c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
|
c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
|
||||||
@@ -459,13 +463,13 @@
|
|||||||
s[0] ^= RC[n];
|
s[0] ^= RC[n];
|
||||||
s[1] ^= RC[n + 1];
|
s[1] ^= RC[n + 1];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if (COMMON_JS) {
|
if (COMMON_JS) {
|
||||||
module.exports = methods;
|
module.exports = methods;
|
||||||
} else if (root) {
|
} else {
|
||||||
for (var key in methods) {
|
for (var i = 0; i < methodNames.length; ++i) {
|
||||||
root[key] = methods[key];
|
root[methodNames[i]] = methods[methodNames[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(this));
|
})();
|
||||||
|
|||||||
+28
-1
@@ -1,4 +1,28 @@
|
|||||||
expect = require('expect.js');
|
expect = require('expect.js');
|
||||||
|
|
||||||
|
// Node.js env
|
||||||
|
var sha3 = require('../src/sha3.js');
|
||||||
|
keccak_512 = sha3.keccak_512;
|
||||||
|
keccak_384 = sha3.keccak_384;
|
||||||
|
keccak_256 = sha3.keccak_256;
|
||||||
|
keccak_224 = sha3.keccak_224;
|
||||||
|
sha3_512 = sha3.sha3_512;
|
||||||
|
sha3_384 = sha3.sha3_384;
|
||||||
|
sha3_256 = sha3.sha3_256;
|
||||||
|
sha3_224 = sha3.sha3_224;
|
||||||
|
shake_128 = sha3.shake_128;
|
||||||
|
shake_256 = sha3.shake_256;
|
||||||
|
require('./test.js');
|
||||||
|
require('./test-shake.js');
|
||||||
|
|
||||||
|
delete require.cache[require.resolve('../src/sha3.js')];
|
||||||
|
delete require.cache[require.resolve('./test.js')];
|
||||||
|
delete require.cache[require.resolve('./test-shake.js')];
|
||||||
|
|
||||||
|
// Webpack browser env
|
||||||
|
JS_SHA3_NO_NODE_JS = true;
|
||||||
|
window = global;
|
||||||
|
expect = require('expect.js');
|
||||||
var sha3 = require('../src/sha3.js');
|
var sha3 = require('../src/sha3.js');
|
||||||
keccak_512 = sha3.keccak_512;
|
keccak_512 = sha3.keccak_512;
|
||||||
keccak_384 = sha3.keccak_384;
|
keccak_384 = sha3.keccak_384;
|
||||||
@@ -27,7 +51,10 @@ keccak_224 = null;
|
|||||||
shake_128 = null;
|
shake_128 = null;
|
||||||
shake_256 = null;
|
shake_256 = null;
|
||||||
|
|
||||||
JS_SHA3_TEST = true;
|
// browser env
|
||||||
|
JS_SHA3_NO_NODE_JS = true;
|
||||||
|
JS_SHA3_NO_COMMON_JS = true;
|
||||||
|
window = global;
|
||||||
require('../src/sha3.js');
|
require('../src/sha3.js');
|
||||||
require('./test.js');
|
require('./test.js');
|
||||||
require('./test-shake.js');
|
require('./test-shake.js');
|
||||||
|
|||||||
+4
-3
@@ -2,7 +2,7 @@
|
|||||||
Array.prototype.toHexString = ArrayBuffer.prototype.toHexString = function () {
|
Array.prototype.toHexString = ArrayBuffer.prototype.toHexString = function () {
|
||||||
var array = new Uint8Array(this);
|
var array = new Uint8Array(this);
|
||||||
var hex = '';
|
var hex = '';
|
||||||
for (var i = 0;i < array.length;++i) {
|
for (var i = 0; i < array.length; ++i) {
|
||||||
var c = array[i].toString('16');
|
var c = array[i].toString('16');
|
||||||
hex += c.length == 1 ? '0' + c : c;
|
hex += c.length == 1 ? '0' + c : c;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,8 @@
|
|||||||
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': 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])
|
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': 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])
|
||||||
},
|
},
|
||||||
'ArrayBuffer': {
|
'ArrayBuffer': {
|
||||||
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26': new ArrayBuffer(0)
|
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26': new ArrayBuffer(0),
|
||||||
|
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': 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]).buffer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sha3_384: {
|
sha3_384: {
|
||||||
@@ -263,7 +264,7 @@
|
|||||||
it('should be equal', function () {
|
it('should be equal', function () {
|
||||||
var bytes = [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];
|
var bytes = [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];
|
||||||
var hash = sha3_512.create();
|
var hash = sha3_512.create();
|
||||||
for (var i = 0;i < bytes.length;++i) {
|
for (var i = 0; i < bytes.length; ++i) {
|
||||||
hash.update([bytes[i]]);
|
hash.update([bytes[i]]);
|
||||||
}
|
}
|
||||||
expect(hash.hex()).to.be('01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450');
|
expect(hash.hex()).to.be('01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450');
|
||||||
|
|||||||
Reference in New Issue
Block a user