decrypt method Null safety
override
Decrypts data
created with the encrypt method using a key
created
with generateRandomKey or generateKeyFromPassword methods.
In case the key
is wrong or the data
has been forged, a
MacMismatchException is thrown
Implementation
@override
Future<String?> decrypt(String data, String key) async {
try {
final decrypted = await _channel.invokeMethod("decrypt", {
"data": data,
"key": key,
});
return decrypted;
} on PlatformException catch (e) {
switch (e.code) {
case "mac_mismatch":
throw new MacMismatchException();
default:
rethrow;
}
}
}