如何在flutter项目中实现如下js加密方式?

js实现方式如下

import CryptoJS from 'crypto-js'
encrypt(word) {
    const key = 'key'
    const iv = 'iv'
    var _word = CryptoJS.enc.Utf8.parse(word),
    _key = CryptoJS.enc.Utf8.parse(key),
    _iv = CryptoJS.enc.Utf8.parse(iv)
    var encrypted = CryptoJS.AES.encrypt(_word, _key, {
    iv: _iv,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
    })
    return encrypted.toString()
}
阅读 989
1 个回答

还得靠人来解决

static String encryptAes(
    String plainText,
  ) {
    const key = 'ihaierForTodoKey';
    const iv = 'ihaierForTodo_Iv';
    final _key = encrypt.Key.fromUtf8(key);
    final _iv = encrypt.IV.fromUtf8(iv);
    final encrypter = encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));

    final encrypted = encrypter.encrypt(plainText, iv: _iv);

    return encrypted.base64;
  }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题