encryptUint8List method
Encrypt given Uint8List data.
After encryption returns encrypted Uint8List
Implementation
@override
Uint8List encryptUint8List({Uint8List? data, bool? useCompress}) {
bool _useCompress = useCompress == null ? this.useCompress : useCompress;
if (data == null) {
throw Exception("data cannot be null");
}
final Encrypter _encrypter = Encrypter(AES(_key));
final Encrypted _encrypted =
_encrypter.encrypt(String.fromCharCodes(data), iv: _iv);
List<int>? compressedContent;
if (_useCompress) {
compressedContent = GZipEncoder().encode(_encrypted.bytes.toList())!;
}
return _useCompress
? Uint8List.fromList(compressedContent!)
: _encrypted.bytes;
}