SharpAESCrypt 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpAESCrypt --version 2.0.2                
NuGet\Install-Package SharpAESCrypt -Version 2.0.2                
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="SharpAESCrypt" Version="2.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpAESCrypt --version 2.0.2                
#r "nuget: SharpAESCrypt, 2.0.2"                
#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 SharpAESCrypt as a Cake Addin
#addin nuget:?package=SharpAESCrypt&version=2.0.2

// Install SharpAESCrypt as a Cake Tool
#tool nuget:?package=SharpAESCrypt&version=2.0.2                

SharpAESCrypt

A C# implementation of the AESCrypt file format.

This .NET AES Crypt package contains the C# class SharpAESCrypt.SharpAESCrypt, which provides file encryption and decryption using the aescrypt file format.

Version 2 of the AES File Format is supported for reading and writing. Versions 0 and 1 are not verified, but there is code to read and write the formats.

Downloads

You can install SharpAESCrypt from NuGet.

The library is targeting .NET8. For versions supporting Mono and .NET4, use v1.3.4 with a different codebase.

Usage

With a reference to SharpAESCrypt, the primary interface are static methods:

    using SharpAESCrypt;
    AESCrypt.Encrypt("password", "inputfile", "outputfile");
    AESCrypt.Decrypt("password", "inputfile", "outputfile");
    AESCrypt.Encrypt("password", inputStream, outputStream);
    AESCrypt.Decrypt("password", inputStream, outputStream);

For uses where a stream is required/prefered, streams can also be created by wrapping either output or input:

    var encStream = new EncryptingStream(password, outputStream);
    var decStream = new DecryptingStream(password, inputStream);

Remember to either call Dispose() or FlushFinalBlock() after using the stream.

Options

Generally, it is recommended that only the default options are applied, but it is possible to toggle some options via the optional options parameter.

For encrypting, you can control the written fileversion and what headers to include (if using v2):

var options = new EncryptionOptions(
    InsertCreatedByIdentifier: true,
    InsertTimeStamp: true,
    InsertPlaceholder: true,
    FileVersion: AESCrypt.DEFAULT_FILE_VERSION,
    LeaveOpen: false,
    AdditionalExtensions = new Dictionary<string, byte[]> {
        { "aes", new byte[] { 0x41, 0x45, 0x53 } }
    }
);

SharpAESCrypt.Encrypt("password", "inputfile", "outputfile", options);

For decrypting you can toggle some compatibility options:

var options = new DecyptionOptions(
    MinVersion: 2,
    LeaveOpen: false,
    IgnorePaddingBytes: false,
    IgnoreFileLength: false
);

SharpAESCrypt.Decrypt("password", "inputfile", "outputfile"), options;

The option IgnorePaddingBytes can be set to true to skip a consistency check made by this library. The consistency check counters a length modification vulnerability in the original format. If you need to read files generated by another tool, you may need to toggle this option.

Product Compatible and additional computed target framework versions.
.NET 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.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on SharpAESCrypt:

Repository Stars
duplicati/duplicati
Store securely encrypted backups in the cloud!
Version Downloads Last updated
2.0.3 6,966 10/24/2024
2.0.2 9,799 7/5/2024

Fixed writing bug in async interface. Added cancellation tokens.