From c77ca02cbc428abc9e226d898b4e10743bf1b07d Mon Sep 17 00:00:00 2001 From: "DESKTOP-6C3NK6N\\WXS" <815034831@qq.com> Date: Thu, 19 Sep 2024 17:27:31 +0800 Subject: [PATCH] 1 --- src/utils/encrypt/crypto.js | 17 +++++++++++------ src/utils/encrypt/index.js | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/utils/encrypt/crypto.js b/src/utils/encrypt/crypto.js index 582b96ec..7b55ad35 100644 --- a/src/utils/encrypt/crypto.js +++ b/src/utils/encrypt/crypto.js @@ -19,14 +19,19 @@ export const Encrypt = { if (sessionStorage.getItem('PublicKey')) { PublicKey = sessionStorage.getItem('PublicKey'); } else { - let res = await getPublicKey(); - if (res.IsSuccess) { - PublicKey = decodeURI(res.Result) - sessionStorage.setItem('PublicKey', res.Result) - } else { - return false; + try { + let res = await getPublicKey(); + if (res.IsSuccess) { + PublicKey = atob(res.Result) + sessionStorage.setItem('PublicKey', PublicKey) + } else { + return false; + } + } catch (err) { + console.log(err) } } + console.log(PublicKey) let encryptor = new JSEncrypt() encryptor.setPublicKey(PublicKey) return encryptor.encrypt(JSON.stringify(plaintext)) diff --git a/src/utils/encrypt/index.js b/src/utils/encrypt/index.js index 6019ef08..2be2cd66 100644 --- a/src/utils/encrypt/index.js +++ b/src/utils/encrypt/index.js @@ -7,8 +7,8 @@ export const encryptConfig = async (config) => { } if (config.data && Object.prototype.toString.call(config.data) === '[object Object]') { Object.keys(config.data).forEach(async key => { - // config.data[key] = Crypto.AES.encrypt(config.data[key], secretKey) - config.data[key] = await Encrypt.encrypt(config.data[key]) + config.data[key] = Crypto.AES.encrypt(config.data[key], secretKey) + // config.data[key] = await Encrypt.encrypt(config.data[key]) }) } return config;