Giter VIP home page Giter VIP logo

safecrypt's Introduction

SafeCrypt Library

A C# library for encryption and decryption.

Overview

The SafeCrypt library provides a set of methods for encrypting and decrypting data using various encryption algorithms, including the Advanced Encryption Standard (AES) and RSA (Rivest–Shamir–Adleman). It is designed to be easy to use and can be integrated into C# applications that require secure data transmission or storage.

Table of Contents

Installation

To use the SafeCrypt library in your C# project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/selfmadecode/SafeCrypt
    cd SafeCrypt
  2. Build the project:

    dotnet build

Now, you can reference the SafeCrypt library in your C# project.

Aes

To use AES encryption in your C# application, access the static Aes class directly. Call the provided methods;

Check the Aes.md documentation for guidance.

Rsa

This library provides a straightforward implementation of RSA encryption and decryption in C# using the .NET RSACryptoServiceProvider. It includes methods for generating RSA key pairs, encrypting data with a public key, and decrypting data with a private key.

For more details on RSA Encryption, check the Rsa.md document.

Contributing

If you would like to contribute to the development of the SafeCrypt library, follow these steps:

  1. Create an issue to discuss the proposed changes or bug fixes.

  2. Fork the repository and create a new branch for your work:

    git checkout -b feature/my-feature
  3. Make your changes and commit them with clear and concise messages.

  4. Push your changes to your fork.

  5. Create a pull request from your branch to the main repository.

  6. Ensure that your pull request follows the contribution guidelines and includes necessary tests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

safecrypt's People

Contributors

casido1 avatar oluwasege avatar selfmadecode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

safecrypt's Issues

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.

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();

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

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.

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.