decrypt method

List<int> decrypt(
  1. String value
)

Decrypts the given value and returns the resulting bytes. This expects the passed in value to be of the format: ${rsaEncryptedAesKey}:${base64Iv}:${base64EncryptedValue}

Implementation

List<int> decrypt(String value) {
  final parts = value.split(':');
  final encrypted = '${parts[1]}:${parts[2]}';

  final aes = _aes ?? Aes();

  final privateKey = _privateKey;
  if (privateKey == null) {
    throw Exception('RSA attempted to decrypt but [privateKey] is null');
  }

  final key = RSA(
    encoding: _encoding,
    privateKey: privateKey,
  ).decrypt(
    Encrypted.fromBase64(parts[0]),
  );

  final result = aes.key(key).decrypt(encrypted);

  return result;
}