对比新文件 |
| | |
| | | import CryptoJS from 'crypto-js'; |
| | | import AES from 'crypto-js/aes'; |
| | | import enc from 'crypto-js/enc-utf8'; |
| | | |
| | | // 瑙e瘑鏂规硶 |
| | | export function Decrypt(word, keyStr, ivStr) { |
| | | const key = CryptoJS.enc.Utf8.parse(keyStr); |
| | | const iv = CryptoJS.enc.Utf8.parse(ivStr); |
| | | const encryptedHexStr = CryptoJS.enc.Hex.parse(word); |
| | | const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr); |
| | | const decrypt = AES.decrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); |
| | | const decryptedStr = decrypt.toString(enc.Utf8); |
| | | return decryptedStr; |
| | | } |
| | | // const plaintext = 'your plaintext'; |
| | | // const key = 'your encryption key'; |
| | | // const iv = 'your initialization vector'; |
| | | // |
| | | // const encrypted = CryptoJS.AES.encrypt(plaintext, key, { iv: iv }); |
| | | // const ciphertext = encrypted.toString(); |
| | | // console.log('ciphertext',ciphertext) |