我使用CryptoJS而不是nodejscrypto模块,因为我只使用本机JavaScript,但有些代码不能工作:
function aesEncrypt(text, secKey) {
const _text = text
const lv = new Buffer('0102030405060708', 'binary')
const _secKey = new Buffer(secKey, 'binary')
const cipher = crypto.createCipheriv('AES-128-CBC', _secKey, lv)
let encrypted = cipher.update(_text, 'utf8', 'base64')
encrypted += cipher.final('base64')
return encrypted
}
Run Code Online (Sandbox Code Playgroud)
那么我应该如何修改这些代码呢?