我正在尝试解密 dart 中的加密文本。我收到错误消息 Unhandled Exception: Invalid argument(s): Input data length must be a multiple of cipher's block size
。我不太确定错误是什么意思。谷歌并没有真正的帮助。这是我的代码。
void main() {
final key = Key.fromUtf8('put32charactershereeeeeeeeeeeee!'); //32 chars
final iv = IV.fromUtf8('put16characters!'); //16 chars
//encrypt
String encryptMyData(String text) {
final e = Encrypter(AES(key, mode: AESMode.cbc));
final encrypted_data = e.encrypt(text, iv: iv);
return encrypted_data.base64;
}
//dycrypt
String decryptMyData(String text) {
final e = Encrypter(AES(key, mode: AESMode.cbc));
final decrypted_data = e.decrypt(Encrypted.fromBase64(text), iv: iv);
return decrypted_data;
}
decryptMyData("gAAAAABiDgiJAH4FI9E1aNLl1hv19VR61rLVEdjIrEElU-tcCDOvADPFbO1JhemTFyMG2S-YSsFgUxOJ-QjnNGBfyfJzytsEQUCDkBNdQUTSryj74tp7dV1gh_BzJOxTGPgVA3AGaVcKeL1_CLiIRzJc0l0L_Xa_3FHEG2MP7jdSUgqCvmpggp8wf5_7nANHIxlXN6ikcfGUbGDjDch4PovRnqLp5nEHGUl3l9zNG3JmK09yKEjjEkbGIf4VTIWuIvbdUae87jfIOhVTiil9T9BT1YYd2Ob6iKioVaTAVaVCmM8Oi9qNdrHqwdpXuUfpGBHWMXgsNtSMUAwJ7W19fHDgCzqVA0ENLp2rZqtIN7leL4JSHbGEEA2C4HYNt5wab6hPjiLxlvFaoPBfgIXiMjt7XqFrBy3koZuGj1iPOe8KRe0IxEArWMnGX_I_QIqcai0BU0GDQygQ5IsSud-GH3FuyGwGlWI3O4p5SkJEkaQ4B2Z0tbE0491qzNtt5SKaNc24KWHb-bkIR3ekjE6G6t8b3t_GYlKTvfYDebcO1PfoLjvh8Uy28xw3YRKAzwJCUhhom7jbyJnXvie9gQRSFNLx-59GuRVx5u0CJCQxH583yKuX2R1wj9Qb-xg8tD_IZCrdP-mf07qhnU-2X-G-YQfXiW1y2_BZnIolG6_gec5f9HbaPbZkUZ15sv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