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

Encryption between platforms #327

Open
blob84 opened this issue Jan 28, 2024 · 1 comment
Open

Encryption between platforms #327

blob84 opened this issue Jan 28, 2024 · 1 comment

Comments

@blob84
Copy link

blob84 commented Jan 28, 2024

If I encrypt from windows, browser or native, app doesn't decrypt on android.
If I encrypt from linux, app does decrypt succesfully on android.
Do you know how to create functions, encrypt and decrypt, platform independent?

Here the code:

String encryptAES(String originalText, Key secretKey) {
  final encrypter = Encrypter(AES(secretKey, mode: AESMode.cbc));
  final encrypted = encrypter.encrypt(originalText, iv: IV.fromLength(16));
  return encrypted.base64;
}

String decryptAES(String encryptedText, Key secretKey) {
  final encrypter = Encrypter(AES(secretKey, mode: AESMode.cbc));
  final encrypted = Encrypted.fromBase64(encryptedText);
  final decrypted = encrypter.decrypt(encrypted, iv: IV.fromLength(16));
  return decrypted;
}
@mozomig
Copy link

mozomig commented Sep 26, 2024

try save IV when you call encrypt and use it for decrypt on other platform, IV.fromLength must be return random IV each call

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

2 participants