FlowEncrypt 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package FlowEncrypt --version 1.0.4                
NuGet\Install-Package FlowEncrypt -Version 1.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FlowEncrypt" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FlowEncrypt --version 1.0.4                
#r "nuget: FlowEncrypt, 1.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FlowEncrypt as a Cake Addin
#addin nuget:?package=FlowEncrypt&version=1.0.4

// Install FlowEncrypt as a Cake Tool
#tool nuget:?package=FlowEncrypt&version=1.0.4                

FlowEncrypt

Description

FlowEncrypt is a C# library providing robust encryption and decryption functionalities for files and in-memory data. Utilizing AES encryption with support for asymmetric key encryption of the salt, this library ensures secure handling of sensitive data.

Features

  • Encrypt and decrypt data streams, files and byte arrays (IEnumerable).
  • Support for RSA public/private key pair for salt encryption in AES.
  • Simple and intuitive API.
  • Secure and efficient implementation.

Getting Started

Prerequisites

  • .NET 8.0 or later.

Installation

Clone the repository to your local machine:

git clone https://github.com/forReason/FlowEncrypt.git

Usage

File Encryption and Decryption
string inputFile = "path/to/input.txt";
string encryptedFile = "path/to/encrypted.txt";
string decryptedFile = "path/to/decrypted.txt";
string password = "yourStrongPassword";

// Encrypting a file
EncryptFiles.Encrypt(inputFile, eoutputFile, password);

// Decrypting a file
EncryptFiles.Decrypt(inputFile, outputFile, password);
In-Memory Data Encryption and Decryption
string originalText = "Hello, World!";
IEnumerable<byte> data = Encoding.UTF8.GetBytes(originalText);

// Encrypting data
IEnumerable<byte> encryptedData = EncryptData.Encrypt(data, password);

// Decrypting data
IEnumerable<byte> decryptedData = EncryptData.Decrypt(encryptedData, password);

Usage with streams

Basic Encryption
using MemoryStream outputStream = new MemoryStream(dataToEncrypt);
using (EncryptingStream encryptStream = new (outputStream, password, publicKey: null))
{
    encryptStream.Write(originalData, 0, originalData.Length);
}
Basic Decryption
using MemoryStream inputStream = new MemoryStream(encryptedData);
using DecryptingStream decryptStream = new DecryptingStream(inputStream, password);

using StreamReader reader = new StreamReader(decryptStream);
string decryptedText = reader.ReadToEnd();
Encryption with Public Key

If the data was encrypted using a public key:

(X509Certificate2 PublicKey, X509Certificate2 PrivateKey) keys = HelperFunctions.GenerateKeys();

using MemoryStream outputStream = new ();
using (EncryptingStream encryptStream = new (outputStream, password, keys.PublicKey))
{
    encryptStream.Write(originalData, 0, originalData.Length);
}
Decryption with Private Key

If the data was encrypted using a public key:

(X509Certificate2 PublicKey, X509Certificate2 PrivateKey) keys = HelperFunctions.GenerateKeys();

using MemoryStream inputStream = new MemoryStream(encryptedDataWithPublicKey);
using DecryptingStream decryptStream = new DecryptingStream(inputStream, password, keys.PrivateKey);

using StreamReader reader = new StreamReader(decryptStream);
string decryptedTextWithPrivateKey = reader.ReadToEnd();

Notes

  • Ensure that the EncryptStream and DecryptStream are properly disposed of to release all resources.
  • For encryption with a public key, ensure the corresponding private key is available for decryption.
  • These classes are designed to work seamlessly with streams, making them versatile for various data sources.

Contributing

Contributions are welcome! Please read our Contributing Guide for more information.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FlowEncrypt:

Package Downloads
SimpleBackup

SimpleBlackup is an easy to use, simple and lightweight backup and restore library for creating and restoring file backups. supports plain, compressed and encrypted backups.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 200 12/27/2023
1.0.4 166 11/29/2023
1.0.3 120 11/29/2023
1.0.2 117 11/29/2023
1.0.1 123 11/29/2023
1.0.0 127 11/29/2023

clarified constructors for EncryptFiles
code cleanups