初始化

This commit is contained in:
hezhidong
2025-03-28 09:19:45 +08:00
parent a920f6f06a
commit 91514490ea
25 changed files with 7952 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
//import CryptoJS from '@/../node_modules/crypto-js/crypto-js.js'
import CryptoJS from "./js/crypto-js.js";
// DES加密
export const encryptDes = (message, key) => {
const keyHex = CryptoJS.enc.Utf8.parse(key);
const encrypted = CryptoJS.DES.encrypt(message, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString();
}
// DES解密
export const decryptDes = (ciphertext, key) => {
const keyHex = CryptoJS.enc.Utf8.parse(key);
// direct decrypt ciphertext
const decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
}, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
}