Data.fromEncrypted constructor

Data.fromEncrypted({
  1. required String encrypted,
  2. String? encryptionKey,
})

Implementation

factory Data.fromEncrypted({
  required String encrypted,
  String? encryptionKey,
}) {
  if (encryptionKey == null) throw EncryptionKeyException();
  EncryptionService encryptionService = EncryptionService();

  try {
    final json =
        encryptionService.decryptPushWithAes(encryptionKey, encrypted);
    return Data.fromJson(json);
  } catch (e) {
    throw EncryptionKeyException();
  }
}