Skip to content

Commit

Permalink
fix sha256 access deny
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Dec 25, 2023
1 parent 758f829 commit 0b9245b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/utils/webcrypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit 0b9245b

Please sign in to comment.