aes/cbc/pkcs5padding 加密和解密颤振

时间:2021-07-19 13:10:02

标签: flutter encryption error-handling aes

static String encKey = 'oasterw4567ncdsagfhswtoslfiessgv';
  static final key = encrypt.Key.fromUtf8(encKey);
  static final iv = encrypt.IV.fromLength(16);

  static final encrypter = encrypt.Encrypter(
      encrypt.AES(key, mode: encrypt.AESMode.cbc, padding: 'PKCS7'));

  static encryptAES(text) {
    final encrypted = encrypter.encrypt(text, iv: iv);
    print("Encrypted " + encrypted.base64);
    decryptAES(encrypted.base64);
    return encrypted.base64;
  }

  static decryptAES(encText) {
    String original =
        encrypter.decrypt(encrypt.Encrypted.from64(encText), iv: iv);
    print("Decrypt  " + original);
  }
<块引用>

这是简单的 AES 算法,但现在客户端需要 aes/cbc/pkcs5padding 那么我该如何转换?

0 个答案:

没有答案
相关问题