请教一下关于AES加密问题!!

AES/CFB/NoPadding

向各位大神请教一下关于,Flutter 中需要使用AES加密的问题。

  1. 使用encrypt控件,
  2. 传入的Key位数为16位

代码

 String encryptAes(String content, String aesKey) {
final _aesKey = Key.fromUtf8(aesKey);
final iv = IV.fromUtf8(aesKey);
final _encrypter = Encrypter(AES(_aesKey, mode: AESMode.cfb64,padding: null));
final _encrypted = _encrypter.encrypt(content, iv: iv);
return _encrypted.base64;
}

日志

======== Exception caught by gesture ===============================================================
The following ArgumentError was thrown while handling a gesture:
Invalid argument(s): Input buffer too short

When the exception was thrown, this was the stack:
#0      CFBBlockCipher._encryptBlock (package:pointycastle/block/modes/cfb.dart:120:7)
#1      CFBBlockCipher.processBlock (package:pointycastle/block/modes/cfb.dart:105:13)
#2      AES._processBlocks (package:encrypt/src/algorithms/aes.dart:65:25)
#3      AES.encrypt (package:encrypt/src/algorithms/aes.dart:37:22)
#4      Encrypter.encryptBytes (package:encrypt/src/encrypter.dart:12:19)

使用Padding后没有问题,NoPadding后会报错。
请各位大神指点,感谢了!!!!!!!!!

讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!