decryptWithKey static method
Decrypts the input text by using a 32 byte length key and 16 byte length initialization vector.
Implementation
static String? decryptWithKey(
Uint8List encryptionKey, Uint8List hmacKey, String b64str,
{bool checkHmac = true}) {
final data = base64.decode(b64str);
final components = RNCryptorComponents.fromBuffer(data);
if (components == null || components.header.options != 0) {
return null;
}
if (checkHmac) {
var hmacData =
data.sublist(0, data.length - RNCryptorSettings.hmacLength);
var hmac = _generateHmac(hmacData, hmacKey);
if (!ListEquality().equals(components.hmac, hmac)) {
return null;
}
}
try {
return _decryptCore(
encryptionKey, components.header.iv, components.cipherText);
} catch (e) {
return null;
}
}