Skip to content

Commit

Permalink
FIX: wordArrayToByteArray
Browse files Browse the repository at this point in the history
  • Loading branch information
MythicalBeings committed Feb 23, 2023
1 parent dfd6df9 commit bc79dfb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function wordArrayToByteArray(wordArray, isFirstByteHasSign) {
if (len == 0) {
return new Array(0);
}
var byteArray = new Array(wordArray.sigBytes);
var byteArray = new Array(len * 4);
var offset = 0;
var word;
var i;
Expand All @@ -229,7 +229,8 @@ function wordArrayToByteArray(wordArray, isFirstByteHasSign) {
if (wordArray.sigBytes % 4 > 2) {
byteArray[offset++] = (word >> 8) & 0xff;
}
return byteArray;

return byteArray.slice(0, wordArray.sigBytes);
}

function byteArrayToShortArray(byteArray) {
Expand Down

0 comments on commit bc79dfb

Please sign in to comment.