From bc79dfbf1dccbc84c46e2c5d8ee5b73f025ae43e Mon Sep 17 00:00:00 2001 From: Mythical Beings Date: Thu, 23 Feb 2023 16:38:59 +0100 Subject: [PATCH] FIX: wordArrayToByteArray --- lib/helpers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index e895c85..b9e3448 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -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; @@ -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) {