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)