Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v5.0.3][Web] decrypt incorrect #334

Open
zs-dima opened this issue May 14, 2024 · 7 comments
Open

[v5.0.3][Web] decrypt incorrect #334

zs-dima opened this issue May 14, 2024 · 7 comments

Comments

@zs-dima
Copy link

zs-dima commented May 14, 2024

decrypt incorrect in case of Web release.
the same code decrypt correctly in the debug or encrypt v5.0.1

final key = Key.fromUtf8("key");
final initializationVector = IV.fromLength(16);
final encrypter = Encrypter(AES(key, mode: AESMode.cbc, padding: 'PKCS7'));
return encrypter.decrypt64(this, iv: initializationVector);

Flutter 3.16.4
encrypt v5.0.3

@tipu0710
Copy link

tipu0710 commented May 18, 2024

Facing same issue on web. I'm using encrypt: ^5.0.3. It was working well before. Here is my code.

final _encrypter = Encrypter(
   AES(Key.fromUtf8('key')),
 );
 static final _iv = IV.fromLength(16);
String encrypt(String value) {
   final encrypted = _encrypter.encrypt(value, iv: _iv);
   return encrypted.base64;
 }

String decrypt(String value) {
   var decrypt = _encrypter.decrypt64(value, iv: _iv);
   return decrypt;
 }

@ArslanKhan99
Copy link

Same issue encryption is also wrong as when going to decrypt it its give symbols in return

@ArslanKhan99
Copy link

THIS ID DECRYPTED Value. This is printing console as it was working fine earlier �����Pl��fY�#��~675

@ArslanKhan99
Copy link

It is encryption seems okay but its also wrong because when try to decrypt it on server side it gives the same decrypt show above "x1kNa/Tk0yH13GhvwmfRGirqGqBFxOt03zqWOf5A6WQ="

@wsk321
Copy link

wsk321 commented May 30, 2024

I encountered this issue today, and after reverting to version 5.0.0, it no longer appeared. I hope the author can address this issue for versions post 5.0.0.

@ArslanKhan99
Copy link

the old version was not longer available I sort this issue like below

get version 5.0.1 directory from my pub cached.
update the project according to my project and use this as local dependency its worked now.

@yogithesymbian
Copy link

yogithesymbian commented Sep 20, 2024

I think I misunderstood the documentation.

Finally, I solved it with the help of ChatGPT! After using this library since 2022, the same problem resurfaced in 2024. Now it's resolved. I’m using it on my mobile (Android), and I believe it will work on other specific devices as well. I used padding set to 'PKCS7'.

My issue(story) is that when the decryption has different lengths, it produces different ASCII symbols. 😅 Two years ago, I solved it by simply replacing everything ascii thats already known by debugging.

[log] data encryption : AjLQ/Htb7J/10101p2XXXXXXXXXXXXXXXqFS5fqkBdo=  // "I have censored this data."
[log] data result decryption : {"id": 100001, "XXXX_XXXX": 1}�����//  "I have censored this data."
The numbers below are IDs:
1-99 are safe.
100 contains random ASCII characters (weird characters: �).

101-999 are safe (solved by replacing all ASCII with empty strings).
1,000 contains random ASCII characters (• weird characters: �������).

1,001-9,999 are safe (solved by replacing all ASCII with empty strings).
10,000 contains random ASCII characters (• weird characters: �����).

10,001-99,999 are safe (solved by replacing all ASCII with empty strings).
100,000 contains random ASCII characters (• weird ASCII characters: �����).

100,001-999,999 are safe.

That means my system has encrypted/decrypted more than 100,000 pieces of data :D

Here’s an example for decryption my code :

final encrypter = aes.Encrypter(
        aes.AES(
          key,
          mode: aes.AESMode.cbc,
          padding: 'PKCS7', //  solved !!!
        ),
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants