From c32b7713c07510bb32ba9d9501f8b2f1b6c1f1c8 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Jun 2025 16:09:49 +0800 Subject: [PATCH] [bug fix] encrypt raw data without utf-8 encoding --- src/core/operations/RSAEncrypt.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/operations/RSAEncrypt.mjs b/src/core/operations/RSAEncrypt.mjs index 859ce132..26fceb74 100644 --- a/src/core/operations/RSAEncrypt.mjs +++ b/src/core/operations/RSAEncrypt.mjs @@ -72,9 +72,8 @@ class RSAEncrypt extends Operation { // Load public key const pubKey = forge.pki.publicKeyFromPem(pemKey); // https://github.com/digitalbazaar/forge/issues/465#issuecomment-271097600 - const plaintextBytes = forge.util.encodeUtf8(input); // Encrypt message - const eMsg = pubKey.encrypt(plaintextBytes, scheme, {md: MD_ALGORITHMS[md].create()}); + const eMsg = pubKey.encrypt(input, scheme, {md: MD_ALGORITHMS[md].create()}); return eMsg; } catch (err) { if (err.message === "RSAES-OAEP input message length is too long.") {