mirror of
https://github.com/emn178/js-sha3.git
synced 2026-08-13 03:51:54 +08:00
Fixed ArrayBuffer detection in old browsers.
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
/node_modules/
|
||||
/tests/
|
||||
node_modules/
|
||||
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
node_modules/
|
||||
covreporter
|
||||
my_test
|
||||
/node_modules/
|
||||
/covreporter/
|
||||
/my_test/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
my_test
|
||||
covreporter
|
||||
@@ -1,5 +1,9 @@
|
||||
# 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.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "js-sha3",
|
||||
"version": "0.5.6",
|
||||
"version": "0.5.7",
|
||||
"main": ["src/sha3.js"],
|
||||
"ignore": [
|
||||
"samples",
|
||||
|
||||
Vendored
+2
-15
File diff suppressed because one or more lines are too long
+7
-3
@@ -1,17 +1,21 @@
|
||||
{
|
||||
"name": "js-sha3",
|
||||
"version": "0.5.6",
|
||||
"version": "0.5.7",
|
||||
"description": "A simple SHA-3 / Keccak / Shake hash function for JavaScript supports UTF-8 encoding.",
|
||||
"main": "src/sha3.js",
|
||||
"typings": "index",
|
||||
"types": "index.d.ts",
|
||||
"devDependencies": {
|
||||
"expect.js": "~0.3.1",
|
||||
"jscoverage": "~0.5.9",
|
||||
"mocha": "~2.3.2"
|
||||
"mocha": "~2.3.2",
|
||||
"uglifyjs": "~2.4.10"
|
||||
},
|
||||
"scripts": {
|
||||
"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": {
|
||||
"type": "git",
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
||||
*
|
||||
* @version 0.5.6
|
||||
* @version 0.5.7
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2015-2016
|
||||
* @license MIT
|
||||
@@ -109,8 +109,8 @@
|
||||
}
|
||||
|
||||
Keccak.prototype.update = function (message) {
|
||||
var notString = typeof message != 'string';
|
||||
if (notString && message instanceof ArrayBuffer) {
|
||||
var notString = typeof message !== 'string';
|
||||
if (notString && message.constructor === ArrayBuffer) {
|
||||
message = new Uint8Array(message);
|
||||
}
|
||||
var length = message.length, blocks = this.blocks, byteCount = this.byteCount,
|
||||
@@ -168,7 +168,7 @@
|
||||
Keccak.prototype.finalize = function () {
|
||||
var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
|
||||
blocks[i >> 2] |= this.padding[i & 3];
|
||||
if (this.lastByteIndex == this.byteCount) {
|
||||
if (this.lastByteIndex === this.byteCount) {
|
||||
blocks[0] = blocks[blockCount];
|
||||
for (i = 1; i < blockCount + 1; ++i) {
|
||||
blocks[i] = 0;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
// Node.js env
|
||||
expect = require('expect.js');
|
||||
|
||||
// Node.js env
|
||||
var sha3 = require('../src/sha3.js');
|
||||
keccak_512 = sha3.keccak_512;
|
||||
keccak_384 = sha3.keccak_384;
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
Array.prototype.toHexString = ArrayBuffer.prototype.toHexString = function () {
|
||||
var array = new Uint8Array(this);
|
||||
var hex = '';
|
||||
for (var i = 0;i < array.length;++i) {
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
var c = array[i].toString('16');
|
||||
hex += c.length == 1 ? '0' + c : c;
|
||||
}
|
||||
@@ -264,7 +264,7 @@
|
||||
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 hash = sha3_512.create();
|
||||
for (var i = 0;i < bytes.length;++i) {
|
||||
for (var i = 0; i < bytes.length; ++i) {
|
||||
hash.update([bytes[i]]);
|
||||
}
|
||||
expect(hash.hex()).to.be('01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450');
|
||||
|
||||
Reference in New Issue
Block a user