mirror of
https://github.com/emn178/js-sha3.git
synced 2026-08-12 19:41:36 +08:00
### Fixed
- Fix error in arrayBuffer when there are extra bytes #37 - fixed output if finalized.
This commit is contained in:
+12
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
||||
*
|
||||
* @version 0.9.2
|
||||
* @version 0.9.3
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2015-2023
|
||||
* @license MIT
|
||||
@@ -81,6 +81,14 @@
|
||||
return formatMessage(message)[0].length === 0;
|
||||
};
|
||||
|
||||
var cloneArray = function (array) {
|
||||
var newArray = [];
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
newArray[i] = array[i];
|
||||
}
|
||||
return newArray;
|
||||
}
|
||||
|
||||
var createOutputMethod = function (bits, padding, outputType) {
|
||||
return function (message) {
|
||||
return new Keccak(bits, padding, bits).update(message)[outputType]();
|
||||
@@ -360,6 +368,7 @@
|
||||
HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
|
||||
}
|
||||
if (j % blockCount === 0) {
|
||||
s = cloneArray(s);
|
||||
f(s);
|
||||
i = 0;
|
||||
}
|
||||
@@ -395,6 +404,7 @@
|
||||
array[j] = s[i];
|
||||
}
|
||||
if (j % blockCount === 0) {
|
||||
s = cloneArray(s);
|
||||
f(s);
|
||||
}
|
||||
}
|
||||
@@ -423,6 +433,7 @@
|
||||
array[offset + 3] = (block >> 24) & 0xFF;
|
||||
}
|
||||
if (j % blockCount === 0) {
|
||||
s = cloneArray(s);
|
||||
f(s);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user