From 0b9245bbb9de43d13cbe11240cbcee15e7ba27ff Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Mon, 25 Dec 2023 16:56:01 +0800 Subject: [PATCH] fix sha256 access deny --- lib/utils/webcrypto.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/utils/webcrypto.js b/lib/utils/webcrypto.js index 3d36aa9fd8..3d0d68d018 100644 --- a/lib/utils/webcrypto.js +++ b/lib/utils/webcrypto.js @@ -51,6 +51,7 @@ function decodeBase64(b64) { // need more test async function publicEncrypt(key, data) { + key = key.toString() const pemHeader = "-----BEGIN PUBLIC KEY-----\n"; const pemFooter = "\n-----END PUBLIC KEY-----"; key = key.trim(); @@ -59,14 +60,14 @@ async function publicEncrypt(key, data) { const importedKey = await subtleCrypto.importKey( "spki", decodeBase64(key), - { name: "RSA-OAEP", hash: "SHA-256" }, + { name: "RSA-OAEP", hash: "SHA-1" }, false, ["encrypt"], ); const encryptedData = await subtleCrypto.encrypt( { - name: "RSA-OAEP", + name: "RSA-OAEP" }, importedKey, data,