Giter VIP home page Giter VIP logo

safecrypt's Issues

update readme

The readme file is outdated and needs to be updated to show the new class name and how to use the encrypt methods for AES

Refactor Codebase

Alligning codes written to sonarqube's guidelines, Solid Principles etc.

AES Encryption Mode Specification Support

Hey there! Right now, our encryption automatically goes for the Cipher Block Chaining (CBC) mode, we need to add a cool feature that allows users, pick the encryption mode that suits their needs.

Encryption exception handling

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)
{
}
}`

Exception thrown when using the EncryptToHexStringAsync

the code below will generate an exception

var iv = KeyGenerators.GenerateRandomIVKeyAsString();
var secretKey = KeyGenerators.GenerateAesSecretKey(128);

//assigning values to the params
var encryptionParameters = new EncryptionParameters
{
DataToEncrypt = "YourDataToEncrypt",
IV = iv,
SecretKey = secretKey
};

var encryptionResult = await encryptor.EncryptToHexStringAsync(encryptionParameters);

The EncryptToHexStringAsync method needs to convert the IV key from Hex string to byte array

THE Cause of the error:
byte[] dataBytes = param.IV.ConvertKeysToBytes();

THE FIX: use the HexadecimalStringToByteArray() e=method to convert the IV to
byte[] dataBytes = param.IV.HexadecimalStringToByteArray();

Async Support Implementation

We need to add asynchronous support to the encryption and decryption methods. This upgrade will allow users to leverage asynchronous programming patterns, making the whole process smoother and more responsive.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.