请教一下关于AES加密问题!!
AES/CFB/NoPadding
向各位大神请教一下关于,Flutter 中需要使用AES加密的问题。
- 使用encrypt控件,
- 传入的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后会报错。
请各位大神指点,感谢了!!!!!!!!!
你这个问题我是知道怎么处理的,详见:blog.csdn.net/u014386444/article/d...