加密测试
continuous-integration/drone/push Build is passing Details

uat_us
DESKTOP-6C3NK6N\WXS 2024-09-19 17:34:15 +08:00
parent c77ca02cbc
commit 449e999d43
1 changed files with 3 additions and 3 deletions

View File

@ -17,13 +17,13 @@ export const Encrypt = {
encrypt: async function (plaintext) { encrypt: async function (plaintext) {
let PublicKey = null; let PublicKey = null;
if (sessionStorage.getItem('PublicKey')) { if (sessionStorage.getItem('PublicKey')) {
PublicKey = sessionStorage.getItem('PublicKey'); PublicKey = atob(sessionStorage.getItem('PublicKey'));
} else { } else {
try { try {
let res = await getPublicKey(); let res = await getPublicKey();
if (res.IsSuccess) { if (res.IsSuccess) {
PublicKey = atob(res.Result) PublicKey = atob(res.Result)
sessionStorage.setItem('PublicKey', PublicKey) sessionStorage.setItem('PublicKey', res.Result)
} else { } else {
return false; return false;
} }
@ -34,7 +34,7 @@ export const Encrypt = {
console.log(PublicKey) console.log(PublicKey)
let encryptor = new JSEncrypt() let encryptor = new JSEncrypt()
encryptor.setPublicKey(PublicKey) encryptor.setPublicKey(PublicKey)
return encryptor.encrypt(JSON.stringify(plaintext)) return encryptor.encrypt(plaintext)
}, },