Skip to main content

The Microsoft Data Encryption SDK provides encryption support to applications. It allows developers to implement column- or field-level encryption for data stored in various data stores, including Azure data services. Commonly Used Types: Microsoft.Data.Encryption.Cryptography.DataProtector Microsoft.Data.Encryption.Cryptography.DataEncryptionKey Microsoft.Data.Encryption.Cryptography.KeyEncryptionKey Microsoft.Data.Encryption.Cryptography.EncryptionSettings Microsoft.Data.Encryption.Cryptography.EncryptionKeyStoreProvider Microsoft.Data.Encryption.Cryptography.MicrosoftDataEncryptionException Microsoft.Data.Encryption.Cryptography.PlaintextDataEncryptionKey Microsoft.Data.Encryption.Cryptography.ProtectedDataEncryptionKey When using NuGet 3.x this package requires at least version 3.4.

Total Downloads
257.6K
257,573
Published
Sep 24, 2024
2y ago

Get Started

dotnet add package Microsoft.Data.Encryption.Cryptography --version 1.2.0
ProductVersions
.NET
net6.0net8.0
.NET Standard
netstandard2.0

README

GitHub license Nuget

Overview

Microsoft.Data.Encryption.Cryptography provides encryption support to applications. It allows developers to implement column- or field-level encryption for data stored in various data stores, including Azure data services.

Features

The library provides APIs for objects like encryption keys, serializers, key store provider interfaces, and associated caches.

The module implements cryptographic operations using a two-level key hierarchy composed of:

  • Data Encryption Keys (DEKs) - symmetric keys that encrypt data.
  • Key Encryption Keys (KEKs) - asymmetric keys that encrypt DEKs.

The Cryptography module uses cryptographic algorithms that are fully compatible with Always Encrypted in Azure SQL. The data encryption algorithm is AEAD_AES_256_CBC_HMAC_SHA_256 that is derived from the IETF specification draft at https://tools.ietf.org/html/draft-mcgrew-aead-aes-cbc-hmac-sha2-05. The key encryption algorithm is RSA with OEAP padding. For more information, see Always Encrypted cryptography.

Using the SDK for data protection in Azure

The SDK helps ensure:

  • Interoperability with Always Encrypted in Azure SQL
    • You can load the data, encrypted using the SDK, to databases columns configured with Always Encrypted in Azure SQL.
    • If you ensure the database columns are encrypted in the same way as the data you are inserting, your Azure Data Factory and Spark jobs as well as your applications can transparently decrypt the data stored in the database and run confidential queries using Azure SQL client drivers. This is because the SDK is compatible with Always Encrypted.
    • Similarly, you can move the data from a database in Azure SQL to another service or application without decrypting it. Then, you can use the SDK to decrypt the data where it needs to be decrypted, rather than in an application that directly talks to the database.

Supported Platforms

The SDK currently supports the following platforms:

  • .NET Standard 2.0 or higher

Installation

To install the latest version of Microsoft.Data.Encryption.Cryptography via NuGet, use the following command:

dotnet add package Microsoft.Data.Encryption.Cryptography --version 1.2.0

Changelog

[1.2.0]

Changed
  • Further improved Encryption and Decryption performance and memory allocations

[1.1.0]

Added
  • Added Methods in Microsoft.Data.Encryption.Cryptography.DataProtector
  1. Decrypt(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) -> int

    • This method implements decryption functionality that processes a portion of the input byte array and writes the decrypted data into the output byte array. The return value indicates the number of bytes written. By defining output buffer this can significantly reduce allocations.
  2. Encrypt(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) -> int

    • This methos implement encryption functionality that processes a portion of the input byte array and writes the encrypted data into the output byte array. The return value indicates the number of bytes written. By defining output buffer this can significantly reduce allocations.
  3. GetDecryptByteCount(int inputSize) -> int

    • Returns upper bound of bytes required for decryption output based on the given input size.
  4. GetEncryptByteCount(int inputSize) -> int

    • Returns the number of bytes required for encryption output based on the given input size.
Changed
  • AeadAes256CbcHmac256EncryptionAlgorithm is now sealed.
  • CryptographyExtensions.FromHexString implementation is 2-3x faster while allocating 90-97% less memory (applicable only to .NET6.0+)

[1.0.0]

Changed
  • Significant performance and memory optimizations while sustaining current API.

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.