### Fixed

- Fix error in arrayBuffer when there are extra bytes #37
- fixed output if finalized.
This commit is contained in:
Yi-Cyuan Chen
2023-12-16 10:15:26 +08:00
parent 707ee7ced1
commit a6f6da7483
6 changed files with 33 additions and 10 deletions
+12 -1
View File
@@ -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);
}
}