Skip to content

Commit

Permalink
Merge pull request #25 from MythicalBeings/master
Browse files Browse the repository at this point in the history
FIX: Decrypt (wordArrayToByteArray) and compatibility
  • Loading branch information
mrv777 authored Feb 23, 2023
2 parents dfd6df9 + 08e50bf commit f5a1640
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import BigInteger from "jsbn";
import * as pako from "pako";
import cryptoJs from "crypto-js";
import hex from "crypto-js/enc-hex";
import { Buffer } from "buffer";

function rsConvert(address) {
var addr = new NxtAddress();
Expand Down
6 changes: 4 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cryptoJs from "crypto-js";
import hex from "crypto-js/enc-hex";
import { BigInteger } from "jsbn";
import { Buffer } from "buffer";

var charToNibble = {};
var nibbleToChar = [];
Expand Down Expand Up @@ -205,7 +206,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 +230,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 f5a1640

Please sign in to comment.