MD5 2.4.0

dotnet add package MD5 --version 2.4.0
                    
NuGet\Install-Package MD5 -Version 2.4.0
                    
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="MD5" Version="2.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MD5" Version="2.4.0" />
                    
Directory.Packages.props
<PackageReference Include="MD5" />
                    
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 MD5 --version 2.4.0
                    
#r "nuget: MD5, 2.4.0"
                    
#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 MD5@2.4.0
                    
#: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=MD5&version=2.4.0
                    
Install as a Cake Addin
#tool nuget:?package=MD5&version=2.4.0
                    
Install as a Cake Tool

Nuget Nuget codecov

MD5

NuGet

Overview

MD5 is a .NET library that provides methods to generate MD5 hash from string, byteArray, object or stream content. It uses the System.Security.Cryptography.MD5 class to generate the hash.

Usage

To use the library, you can call the GetMD5 method on a string, byteArray, object or stream to get the MD5 hash. Examples:

string hash1 = "hello world".GetMD5();
// or specific encoding type
string hash2 = "hello world".GetMD5(EncodingType.UTF8);
var stream = File.OpenRead("Rondonia.pdf");
string hash = stream.GetMD5();
byte[] byteArray = Encoding.UTF8.GetBytes("Hello, World!");
string hash = byteArray.GetMD5();
BrasilModel obj = new BrasilModel() { Id = 1, Details = "Maior país da América do Sul" };
string hash = obj.GetMD5();

For a number, you can use:

string hash = myNumber.ToString().GetMD5();

SHA-256 and HMAC-SHA-256

For new integrity scenarios, use the new GetSHA256 and GetHMACSHA256 methods. They are additional APIs and do not change the existing MD5 method signatures or their historical behavior.

SHA-256 is appropriate for public checksums, fingerprints and content integrity. HMAC-SHA-256 is appropriate when integrity and authenticity depend on a shared secret key. HMAC is not a password-hashing function; use the password-specific APIs below for passwords.

The new methods support strings, byte arrays, objects and streams, just like the existing MD5 methods. String and object inputs use UTF-8 by default.

string sha256 = "hello world".GetSHA256();

string secretKey = "a-secret-key";
string hmac = "hello world".GetHMACSHA256(secretKey);

For binary data and keys:

byte[] payload = Encoding.UTF8.GetBytes("Hello, World!");
byte[] key = Encoding.UTF8.GetBytes("a-secret-key");

string sha256 = payload.GetSHA256();
string hmac = payload.GetHMACSHA256(key);

Password hashing: PBKDF2, bcrypt and Argon2id

For password storage and authentication, use PasswordHash. These algorithms are deliberately separate from the legacy MD5 and salted-MD5 methods. Each Hash... method generates a random salt and returns a self-contained encoded value with the parameters required by its matching Verify... method.

Argon2id is the preferred choice for new password storage when the deployment environment supports it. PBKDF2-HMAC-SHA256 is a broadly compatible alternative, and bcrypt is useful when compatibility with existing bcrypt hashes is required.

string pbkdf2 = PasswordHash.HashPBKDF2("my password");
bool pbkdf2Matches = PasswordHash.VerifyPBKDF2("my password", pbkdf2);

string bcrypt = PasswordHash.HashBCrypt("my password");
bool bcryptMatches = PasswordHash.VerifyBCrypt("my password", bcrypt);

string argon2 = PasswordHash.HashArgon2("my password");
bool argon2Matches = PasswordHash.VerifyArgon2("my password", argon2);

Store the returned encoded value and verify the supplied password against it; never store the plaintext password. Password hashing is intentionally slower than a checksum, so tune the parameters for the production hardware and periodically review them. The existing GetMD5, GetMD5WithSalt, GetSHA256 and GetHMACSHA256 contracts and behavior are unchanged.

New Feature: MD5 with Salt

This feature generates the legacy salted MD5 variants supported by the package. A salt does not make MD5 suitable for password storage or authentication.

Usage

To use the salted hash functionality, you can call the GetMD5WithSalt method on a string, byte array, object or stream to get the legacy salted MD5 result.

The existing overloads intentionally retain their historical behavior for compatibility: string and object values hash salt + content, while byte arrays and streams hash content + salt. Do not change the order when reproducing hashes generated by older versions. Examples:

string salt = "randomSalt";
string hash1 = "hello world".GetMD5WithSalt(salt);
// or specific encoding type
string hash2 = "hello world".GetMD5WithSalt(salt, EncodingType.UTF8);
byte[] byteArray = Encoding.UTF8.GetBytes("Hello, World!");
byte[] saltBytes = Encoding.UTF8.GetBytes("randomSalt");
string hash = byteArray.GetMD5WithSalt(saltBytes);
BrasilModel obj = new BrasilModel() { Id = 1, Details = "Maior país da América do Sul" };
string salt = "randomSalt";
string hash = obj.GetMD5WithSalt(salt);

For a number, you can use:

string salt = "randomSalt";
string hash = myNumber.ToString().GetMD5WithSalt(salt);

Installation

You can install the library via NuGet package manager by searching for MD5 or by executing the following command in the Package Manager Console:

PM> Install-Package MD5

License

This library is licensed under the MIT License. See the LICENSE file for more details.

Contributions

Contributions to this library are welcome. Please open an issue or submit a pull request with your changes.

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 was computed.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MD5:

Package Downloads
HashingTools

کتابخانه‌ی قدرتمند و سبک برای هش کردن داده‌ها با الگوریتم‌های متنوع. شامل الگوریتم‌های MD5, SHA1, SHA256, bcrypt و Argon2. مناسب برای ذخیره‌سازی امن پسوردها، بررسی یکپارچگی فایل‌ها و تولید کلید. با پشتیبانی از Dependency Injection در پروژه‌های ASP.NET Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.0 38 9/7/2026
2.3.0 54 9/6/2026
2.2.5 146,658 7/24/2024
2.1.5 13,566 4/25/2024
2.0.5 15,492 3/6/2024
2.0.4 57,064 8/1/2023
2.0.3 35,920 2/22/2023
2.0.2 65,053 3/25/2022
2.0.1 1,520 3/25/2022
2.0.0 18,116 3/11/2020
1.0.0 2,021 3/11/2020

Added PBKDF2, bcrypt and Argon2id password-hashing APIs without changing existing MD5, SHA-256 or HMAC-SHA-256 signatures or behavior.