raise events on error
This commit is contained in:
@@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
<Product>Pilz.Cryptography</Product>
|
||||
<Copyright>Copyright © 2020</Copyright>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile>D:\repos\Pilz\Pilz.Cryptography\Pilz.Cryptography.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Management" Version="4.7.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
|
||||
Reference in New Issue
Block a user