XlsxCrypt.NativeExcelEncryption 1.1.2

dotnet add package XlsxCrypt.NativeExcelEncryption --version 1.1.2
                    
NuGet\Install-Package XlsxCrypt.NativeExcelEncryption -Version 1.1.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="XlsxCrypt.NativeExcelEncryption" Version="1.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XlsxCrypt.NativeExcelEncryption" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="XlsxCrypt.NativeExcelEncryption" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XlsxCrypt.NativeExcelEncryption --version 1.1.2
                    
#r "nuget: XlsxCrypt.NativeExcelEncryption, 1.1.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.
#:package XlsxCrypt.NativeExcelEncryption@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XlsxCrypt.NativeExcelEncryption&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=XlsxCrypt.NativeExcelEncryption&version=1.1.2
                    
Install as a Cake Tool

XlsxCrypt.NativeExcelEncryption

Native .NET library for password-based encryption and decryption of Excel .xlsx workbooks.

Features

  • Native .NET implementation
  • Excel-compatible workbook encryption
  • Encrypt and decrypt password-protected .xlsx files
  • Uses the Office Agile Encryption format
  • AES-256-CBC encryption
  • SHA-512 hashing
  • Password-based key derivation
  • HMAC-SHA512 data integrity verification
  • No EPPlus dependency
  • No ClosedXML dependency
  • No Microsoft Office installation required
  • Designed for server-side and automated environments

Installation

Install the NuGet package:

dotnet add package XlsxCrypt.NativeExcelEncryption

Or using the NuGet Package Manager:

Install-Package XlsxCrypt.NativeExcelEncryption

Usage

Encrypt

using XlsxCrypt;

ExcelEncryption.EncryptFile(
    "input.xlsx",
    "encrypted.xlsx",
    "your-password");

Decrypt

using XlsxCrypt;

ExcelEncryption.DecryptFile(
    "encrypted.xlsx",
    "decrypted.xlsx",
    "your-password");

Complete Example

using XlsxCrypt;

string inputFile = @"C:\Excel\input.xlsx";
string encryptedFile = @"C:\Excel\encrypted.xlsx";
string decryptedFile = @"C:\Excel\decrypted.xlsx";

string password = "StrongPassword123!";

// Encrypt unencrypted .xlsx
ExcelEncryption.EncryptFile(
    inputFile,
    encryptedFile,
    password);

// Decrypt password-protected .xlsx
ExcelEncryption.DecryptFile(
    encryptedFile,
    decryptedFile,
    password);

Note: NativeExcelEncryption.EncryptFile and NativeExcelEncryption.DecryptFile are also available as direct entry points.

How It Works

XlsxCrypt uses Microsoft's Office Agile Encryption format to protect .xlsx workbooks.

The workbook package is encrypted using AES-256-CBC with 4096-byte segments. The encrypted package, encryption metadata, and Office DataSpaces information are stored in an OLE Compound File.

The encryption process includes:

  • Password-based key derivation
  • SHA-512 hashing
  • AES-256-CBC encryption
  • Random salts
  • Password verification
  • Encrypted workbook key
  • HMAC-SHA512 integrity verification
  • Office DataSpaces metadata
  • EncryptionInfo
  • EncryptedPackage

Decryption reverses this process and verifies the password and encrypted package integrity before producing the original .xlsx workbook.

Why XlsxCrypt?

XlsxCrypt provides a native .NET approach to Excel workbook encryption without requiring:

  • EPPlus
  • ClosedXML
  • Microsoft Office
  • Excel COM automation

This makes it suitable for applications that need to protect Excel workbooks programmatically, particularly server-side and automated workloads.

Compatibility

The library uses the Microsoft Office Agile Encryption format and is intended to produce password-protected .xlsx workbooks compatible with Microsoft Excel.

Always test encrypted workbooks with the Excel versions and environments relevant to your application before using the library in production.

Security

This library implements cryptographic operations required by the Office Agile Encryption format.

The security of an encrypted workbook also depends on the password used to protect it.

Recommendations:

  • Use strong, unique passwords.
  • Do not hard-code passwords in source code.
  • Do not log passwords.
  • Store passwords securely.
  • Test the library thoroughly before using it for highly sensitive or regulated data.

This project has not been presented as a replacement for a formal security review or cryptographic audit.

Requirements

  • .NET 10
  • Windows

Release Notes

v1.1.1

  • Fixed Office Agile Encryption data integrity HMAC key size for SHA-512 compliance.
  • Fixed OLE Compound File DataSpaces structure, alignment, and version metadata streams.
  • Added full workbook decryption support (DecryptFile) with package integrity and password verification.

License

MIT License.

See the LICENSE file for the complete license text.

Repository

Source code and development history are available on GitHub:

https://github.com/pragmasujit/xlscrypt

Disclaimer

XlsxCrypt.NativeExcelEncryption is an independent open-source project and is not affiliated with, sponsored by, or endorsed by Microsoft Corporation.

Excel and Microsoft Office are trademarks of Microsoft Corporation.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.2 71 10/2/2026
1.1.1 73 10/2/2026
1.0.0 74 10/1/2026