decrypt static method
Encrypts the input text by using the specified password.
Implementation
static String? decrypt(String password, String b64str,
{bool checkHmac = true}) {
final data = base64.decode(b64str);
final components = RNCryptorComponents.fromBuffer(data);
if (components == null || components.header.options != 1) {
return null;
}
if (checkHmac) {
var hmacKey = generateKey(password, components.header.hmacSalt!);
var hmacData =
data.sublist(0, data.length - RNCryptorSettings.hmacLength);
var hmac = _generateHmac(hmacData, hmacKey);
if (!ListEquality().equals(components.hmac, hmac)) {
return null;
}
}
try {
final key = generateKey(password, components.header.encryptionSalt!);
return _decryptCore(key, components.header.iv, components.cipherText);
} catch (e) {
return null;
}
}