From f51924bf1da3af70d2b99486bda1078ef45c782f Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 13 Sep 2022 11:36:01 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?key=E5=B0=B1=E4=B8=8D=E5=8A=A0=E5=AF=86=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/crypto.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/crypto.js b/src/utils/crypto.js index 74d3f474f..a267f621b 100644 --- a/src/utils/crypto.js +++ b/src/utils/crypto.js @@ -37,10 +37,13 @@ export function encryptPassword(password) { if (!password) { return '' } + let rsaPublicKeyText = getCookie('jms_public_key') + if (!rsaPublicKeyText) { + return password + } const aesKey = (Math.random() + 1).toString(36).substring(2) // public key 是 base64 存储的 - const rsaPublicKeyText = getCookie('jms_public_key') - .replaceAll('"', '') + rsaPublicKeyText = rsaPublicKeyText.replaceAll('"', '') const rsaPublicKey = atob(rsaPublicKeyText) const keyCipher = rsaEncrypt(aesKey, rsaPublicKey) const passwordCipher = aesEncrypt(password, aesKey)