decryptWithKey function Null safety

Future<List<int>> decryptWithKey(
  1. {dynamic encrypted,
  2. required EncryptionKey key}
)

Provided an encrypted+serialized string (in Cryppo's encryption serialization format) and a Key (the type of which depends on the type of encryption used) return the decrypted binary data.

Implementation

Future<List<int>> decryptWithKey({dynamic encrypted, required EncryptionKey key}) async {
  if (encrypted is String) {
    return _decryptSerialized(encrypted, key);
  } else if (encrypted is EncryptionResult) {
    return encrypted.strategy
        .toService()
        .decryptEncryptionResultWithKey(encrypted, key);
  } else {
    throw Exception(
        'encryptedObject is neither a serialised String or an EncryptionResult');
  }
}