diff --git a/Pilz.Cryptography/AESStringCrypter.cs b/Pilz.Cryptography/AESStringCrypter.cs
index 54afc8c..4f66c01 100644
--- a/Pilz.Cryptography/AESStringCrypter.cs
+++ b/Pilz.Cryptography/AESStringCrypter.cs
@@ -9,6 +9,7 @@ namespace Pilz.Cryptography
public class AESStringCrypter : ICrypter
{
public delegate void AESStringCrypterEventHandler(AESStringCrypter sender);
+ public delegate void AESStringCrypterErrorEventHandler(AESStringCrypter sender, Exception exception);
///
/// This event throws if no key and no default key was found. You can now provide a key or default key (maybe depending on the given instance). If no value is provided, a default key will be created.
@@ -18,6 +19,8 @@ namespace Pilz.Cryptography
/// This event throws if no IV and no default IV was found. You can now provide a IV or default IV (maybe depending on the given instance). If no value is provided, a default IV will be created.
///
public static event AESStringCrypterEventHandler NeedIV;
+ public static event AESStringCrypterErrorEventHandler ErrorAtDecrypting;
+ public static event AESStringCrypterErrorEventHandler ErrorAtEncrypting;
private byte[] key = new byte[] { };
private byte[] iv = new byte[] { };
@@ -69,8 +72,9 @@ namespace Pilz.Cryptography
{
return DecryptStringFromBytes_Aes(Convert.FromBase64String(encryptedValue), GetKey(), GetIV());
}
- catch (CryptographicException)
+ catch (Exception ex)
{
+ ErrorAtDecrypting?.Invoke(this, ex);
return string.Empty;
}
}
@@ -87,8 +91,9 @@ namespace Pilz.Cryptography
{
return Convert.ToBase64String(EncryptStringToBytes_Aes(plainValue, GetKey(), GetIV()));
}
- catch (CryptographicException)
+ catch (Exception ex)
{
+ ErrorAtEncrypting?.Invoke(this, ex);
return string.Empty;
}
}
diff --git a/Pilz.Cryptography/Pilz.Cryptography.csproj b/Pilz.Cryptography/Pilz.Cryptography.csproj
index 6d5344e..d097b9d 100644
--- a/Pilz.Cryptography/Pilz.Cryptography.csproj
+++ b/Pilz.Cryptography/Pilz.Cryptography.csproj
@@ -5,6 +5,9 @@
Pilz.Cryptography
Copyright © 2020
+
+ D:\repos\Pilz\Pilz.Cryptography\Pilz.Cryptography.xml
+