encrypt
encrypt copied to clipboard
Bad state: IV is required
在encrypt和decrypt方法里,iv是可选参数,即 {IV? iv},但方法中写到 if (iv == null) { throw StateError('IV is required.'); },这导致我不传iv这个参数就会抛异常,这就表示,不管哪种加密方式,都必须传 iv,我认为这里逻辑写的有问题。希望能及时修正。
for the RSA
Algorithm, it doesn't require IV, so I guess I understand why the author put it as optional
for the
RSA
Algorithm, it doesn't require IV, so I guess I understand why the author put it as optional
My current problem is: in my previous project, AES encryption was used, version 4.0.3 was used, iv was not passed (because iv was optional), there was no null-safe at that time; Now, after I upgrade to 5.0.1, if I do not upload IV, I will pass null exception, which makes me very helpless, so I have to upload IV, but this leads to the encryption method is different from the previous project.
Latest 5.0.1 release: Encrypted encrypt/decrypt (Uint8List bytes, {IV? iv}) { if (iv == null) { throw StateError('IV is required.'); }
xxxxxxxxxxx } (This means that either method will run a null-exception if iv is not passed.)
In version 4.0.3, it looks like this: Encrypted encrypt/decrypt (Uint8List bytes, {IV iv}) {
xxxxxxxxxxx } (IV value is not required)
I also think this is a bug
You can pass final IV iv = IV.fromLength(0);
to skip this bug, if you confirm the mode desn't need IV.