You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
I can't decrypt encrypted Uint8List by below decrypt function
the strange thing is it works fine with some data and not working with others
my app is in production and users is crying now :( :) ,
any solution please ?
class EncryptDataBase {
static final key =
encryptLib.Key.fromUtf8('SOMEKEY');
static final iv = encryptLib.IV.allZerosOfLength(16);
static final Uint8List encryptionMarker =
Uint8List.fromList('EN:'.codeUnits);
static Uint8List encrypt(Uint8List data) {
final encrypter = encryptLib.Encrypter(encryptLib.AES(key));
final encrypted = encrypter.encryptBytes(data, iv: iv);
final markerAndData =
Uint8List(encryptionMarker.length + encrypted.bytes.length);
markerAndData.setRange(0, encryptionMarker.length, encryptionMarker);
markerAndData.setRange(
encryptionMarker.length,
markerAndData.length,
encrypted.bytes,
);
return markerAndData;
}
static Uint8List decrypt(Uint8List data) {
if (data.length >= encryptionMarker.length &&
data.sublist(0, encryptionMarker.length).toString() ==
encryptionMarker.toString()) {
final encryptedData = data.sublist(encryptionMarker.length);
final encrypter = encryptLib.Encrypter(encryptLib.AES(key));
return Uint8List.fromList(
encrypter.decryptBytes(encryptLib.Encrypted(encryptedData), iv: iv));
}
// If no marker, return the data as it is
return data;
}
}
the strange thing is it works fine with some data and not working with others
my app is in production and users is crying now :( :) ,
any solution please ?