decrypt static method
Implementation
static Future<String> decrypt(Map<String, dynamic> envelope, String aesKey) async {
final ivB64 = envelope['iv']?.toString() ?? '';
final dataB64 = envelope['data']?.toString() ?? '';
if (ivB64.isEmpty || dataB64.isEmpty) {
throw StateError('invalid aes envelope');
}
final keyBytes = _keyBytes(aesKey);
final algorithm = _cipherForKeyLength(keyBytes.length);
final clear = await algorithm.decrypt(
SecretBox(
base64Decode(dataB64),
nonce: base64Decode(ivB64),
mac: Mac.empty,
),
secretKey: SecretKey(keyBytes),
);
return utf8.decode(clear);
}