Fixed bytesFromHex
This commit is contained in:
parent
f2a602b455
commit
ff60c7d0b0
@ -43,9 +43,15 @@ function bytesToHex (bytes) {
|
||||
function bytesFromHex (hexString) {
|
||||
var len = hexString.length,
|
||||
i,
|
||||
start = 0,
|
||||
bytes = [];
|
||||
|
||||
for (i = 0; i < len; i += 2) {
|
||||
if (hexString.length % 2) {
|
||||
bytes.push(parseInt(hexString.charAt(0), 16));
|
||||
start++;
|
||||
}
|
||||
|
||||
for (i = start; i < len; i += 2) {
|
||||
bytes.push(parseInt(hexString.substr(i, 2), 16));
|
||||
}
|
||||
|
||||
@ -575,7 +581,7 @@ function bytesModPow (x, y, m) {
|
||||
try {
|
||||
var xBigInt = str2bigInt(bytesToHex(x), 16),
|
||||
yBigInt = str2bigInt(bytesToHex(y), 16),
|
||||
mBigInt = str2bigInt(bytesToHex(m), 16, 2),
|
||||
mBigInt = str2bigInt(bytesToHex(m), 16),
|
||||
resBigInt = powMod(xBigInt, yBigInt, mBigInt);
|
||||
|
||||
return bytesFromHex(bigInt2str(resBigInt, 16));
|
||||
|
Loading…
Reference in New Issue
Block a user