selfmadecode / SafeKrypt.Data.Security

A reliable C# nugget package for encrypting and decrypting data.
MIT License
35 stars 12 forks source link

Encryption exception handling #27

Open selfmadecode opened 10 months ago

selfmadecode commented 10 months ago

Implement robust error handling during encryption or decryption, including specific exceptions for different error scenarios, and provide meaningful error messages.

example:

try { // encryption or decryption algorithm here } catch (ArgumentNullException ex) { throw new ArgumentException("Invalid parameter. Ensure all parameters are not null.", ex); } catch (Exception ex) { throw new DecryptionException("Decryption failed. See inner exception for details.", ex); }

// catch IV key and secret key exception

`public class EncryptionException : Exception { public EncryptionException(string message, Exception innerException) : base(message, innerException) { } }

public class DecryptionException : Exception { public DecryptionException(string message, Exception innerException) : base(message, innerException) { } }`

successJohn commented 9 months ago

I would like to implement the encryption exception handling

selfmadecode commented 8 months ago

sure @successJohn you can take this👍, I will work on reviewing the async implementation.