Closed l-7-l closed 1 year ago
Sorry for my English
function parseKey(aesKey) { return { iv: CryptoJS.enc.Hex.parse(padEnd('', 32, '0')), key: CryptoJS.enc.Base64.parse(aesKey), }; } function aesEncrypt(data, aesKey) { const { iv, key, } = parseKey(aesKey); const cipherText = CryptoJS.AES.encrypt(JSON.stringify(data), key, { iv, }).toString(); return cipherText; } // 解密 function aesDecrypt(data, aesKey) { const { iv, key, } = parseKey(aesKey); const bytes = CryptoJS.AES.decrypt(data, key, { iv, }); const decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8)); return decryptedData; }
stackoverflow link
The ctr crate docs should be a good starting point. For decoding Base64 you can use the base64ct crate.
ctr
base64ct
For further help I recommend asking on the URLO forum.
The following code implements AES encryption and decryption using crypto-js, but I don't know how to implement it in Rust.
stackoverflow link