Closed TheSlimvReal closed 1 year ago
hello, unfortunately I came across this problem, please have you solved it?
@doublekai yes, after some digging around I came across this solution. The hex string needs to be parsed to base64
first:
const rsa = new NodeRSA();
const text = "my message";
const encrypted = rsa.encrypt(text, 'hex');
console.log("encrypted", encrypted);
const base64Encrypted = Buffer.from(encrypted, 'hex').toString('base64');
const decrypted rsa.decrypt(base64Encrypted, 'utf8');
console.log("decrypted", decrypted);
I am currently trying to encrypt a string in
hex
because I need to use it as a query param. Withbase64
encoding I would have to url-encode it first due to the special characters inbase64
.I am trying the following code:
However, it always throws me the error:
Any idea why this is happening?
In the source code I found the following line (
nodeRSA.js
line 292) which looks likeNodeRSA
always expects abase64
string?Thanks for any advice or possible solutions!