leocavalcante / encrypt

🔒 A set of high-level APIs over PointyCastle for two-way cryptography.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web release Invalid or corrupted pad block

MichalNemec opened this issue · comments

Hello,
im using encrypt: 5.0.1 and tried even encrypt: 5.0.3

When im running -d chrome in debug -> all okay, without error.
When im running -d chrome in release -> Invalid argument(s): Invalid or corrupted pad block

Here is my implementation:
here is how im using IV

    final hash = //List<int> 16;
    final iv = IV(Uint8List.fromList(hash));

not even this works:

    final iv = IV.fromLength(16);
    final encrypter = Encrypter(AES(key));
    final encrypted = encrypter.encrypt(value, iv: iv);
    print(encrypted.base64);

just in case decryption is needed:

    final iv = IV.fromLength(16);
    final encrypter = Encrypter(AES(key));
    final encrypted = Encrypted.fromBase64(encrypted.base64);
    final decrypted = encrypter.decrypt(encrypted, iv: iv);
    print(decrypted);

Whats the difference between debug and release for this?

Same here, I had to downgrade to and locked in 5.0.1 to make it work again

Replace IV.fromLength(16) to IV.allZerosOfLength(16).

Remember: using an "all-zeros" IVs is not secure.

More info here: #314 (comment)

Replace IV.fromLength(16) to IV.allZerosOfLength(16).

Remember: using an "all-zeros" IVs is not secure.

More info here: #314 (comment)

since its not secure, i dont think this is correct solution.
Its funny, when on debug mode everything works, on release not.