新增前端密码加密工具

This commit is contained in:
wkc
2026-03-30 10:46:33 +08:00
parent 21208d8965
commit fdd1ce5525
4 changed files with 18828 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
import CryptoJS from 'crypto-js'
export function encryptPasswordFields(payload, fields, key) {
const next = { ...payload }
fields.forEach((field) => {
if (next[field]) {
next[field] = CryptoJS.AES.encrypt(next[field], CryptoJS.enc.Utf8.parse(key), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
}).toString()
}
})
return next
}