https://github.com/oalexandrefreire/md5
MD5 is a .NET library that provides methods to generate MD5 hash from string content. It has over 200,000 downloads on NuGet and is available under the MIT License. Contributions are welcome!
https://github.com/oalexandrefreire/md5
csharp csharp-library md5 md5-encode md5-hash netstandard20
Last synced: 4 months ago
JSON representation
MD5 is a .NET library that provides methods to generate MD5 hash from string content. It has over 200,000 downloads on NuGet and is available under the MIT License. Contributions are welcome!
- Host: GitHub
- URL: https://github.com/oalexandrefreire/md5
- Owner: oalexandrefreire
- License: mit
- Created: 2020-03-11T15:22:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T02:23:18.000Z (almost 2 years ago)
- Last Synced: 2026-01-07T10:46:00.193Z (6 months ago)
- Topics: csharp, csharp-library, md5, md5-encode, md5-hash, netstandard20
- Language: C#
- Homepage: https://oalexandrefreire.github.io/MD5/
- Size: 394 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README


[](https://codecov.io/gh/oalexandrefreire/MD5)
# MD5
[](https://www.nuget.org/packages/MD5/)
## 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:
```csharp
string hash1 = "hello world".GetMD5();
// or specific encoding type
string hash2 = "hello world".GetMD5(EncodingType.UTF8);
```
```csharp
var stream = File.OpenRead("Rondonia.pdf");
string hash = stream.GetMD5();
```
```csharp
byte[] byteArray = Encoding.UTF8.GetBytes("Hello, World!");
string hash = byteArray.GetMD5();
```
```csharp
BrasilModel obj = new BrasilModel() { Id = 1, Details = "Maior país da América do Sul" };
string hash = obj.GetMD5();
```
To number you can use:
```csharp
string hash = myNumber.ToString().GetMD5():
```
## New Feature: MD5 with Salt
This new feature allows you to generate a salted MD5 hash, enhancing security.
### Usage
To use the salted hash functionality, you can call the `GetMD5WithSalt` method on a string, byteArray, or object to get the MD5 hash with a salt.
Examples:
```csharp
string salt = "randomSalt";
string hash1 = "hello world".GetMD5WithSalt(salt);
// or specific encoding type
string hash2 = "hello world".GetMD5WithSalt(salt, EncodingType.UTF8);
```
```csharp
byte[] byteArray = Encoding.UTF8.GetBytes("Hello, World!");
byte[] saltBytes = Encoding.UTF8.GetBytes("randomSalt");
string hash = byteArray.GetMD5WithSalt(saltBytes);
```
```csharp
BrasilModel obj = new BrasilModel() { Id = 1, Details = "Maior país da América do Sul" };
string salt = "randomSalt";
string hash = obj.GetMD5WithSalt(salt);
```
To number you can use:
```csharp
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:
```shell
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.