perf: 优化加密,没有rsa则不加密

pull/8881/head
ibuler 2022-09-13 11:26:26 +08:00 committed by Jiangjie.Bai
parent cb2bd0cf2c
commit c26a786287
1 changed files with 6 additions and 3 deletions

View File

@ -1549,10 +1549,13 @@ function encryptPassword(password) {
if (!password) {
return ''
}
const aesKey = (Math.random() + 1).toString(36).substring(2)
// public key base64 存储的
const rsaPublicKeyText = getCookie('jms_public_key')
.replaceAll('"', '')
let rsaPublicKeyText = getCookie('jms_public_key')
if (!rsaPublicKeyText) {
return password
}
const aesKey = (Math.random() + 1).toString(36).substring(2)
rsaPublicKeyText = rsaPublicKeyText.replaceAll('"', '')
const rsaPublicKey = atob(rsaPublicKeyText)
const keyCipher = rsaEncrypt(aesKey, rsaPublicKey)
const passwordCipher = aesEncrypt(password, aesKey)