SimpleHashing 1.0.3.1

Library that makes hashing with PBKDF2 simple and easy.

Install-Package SimpleHashing -Version 1.0.3.1
dotnet add package SimpleHashing --version 1.0.3.1
<PackageReference Include="SimpleHashing" Version="1.0.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleHashing --version 1.0.3.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Welcome to the SimpleHashing wiki!

First download the nuget package and add the namespace "SimpleHashing".

Getting started

Example of generating a hash with the input "12345":

string hash = PBKDF2.Hash("12345");

Example of verifying a generated hash:

string hash = PBKDF2.Hash("12345");
bool equals = PBKDF2.Verify(hash, "12345");//true
bool equals2 = PBKDF2.Verify(hash, "54321");//false

More advanced

Specify the Iterations of PBKDF2(Default = 50000).
Iterations need to be the same when using Verify and Hash,
else the output will be different and Verify will return false.

string hash = PBKDF2.Hash("12345", 30000);
bool equals = PBKDF2.Verify(hash, "12345", 30000);
//Iterations need to be the same, or Verify will return false.

Specify the length of the hash(Default = 32).
This will not be the length of the output.
The length of the output will be: 16 + length of hash.
Those 16 bytes are used to store the random generated salt.

string hash = PBKDF2.Hash(Input, Length: 60);
string hash2 = PBKDF2.Hash(Input, 3000, 60);//With Iterations 
bool equals = PBKDF2.Verify(hash, Input);//Verify will automaticly detect the length

Example of hashing a byte[]

Works the same as hashing a string, but now the input and output is a byte[].

byte[] input = Encoding.UTF8.GetBytes("12345");

byte[] hash = PBKDF2.Hash(input);
bool equals = PBKDF2.Verify(hash, input);

Overloads of all functions

Overloads of the Hash function:

static string Hash(string input, int iterations = 50000, int length = 32)
static byte[] Hash(byte[] input, int iterations = 50000, int length = 32)

Overloads of the Verify function:

static bool Verify(string hashedInput, string input, int iterations = 50000)
static bool Verify(byte[] hashedInput, byte[] input, int iterations = 50000)

Welcome to the SimpleHashing wiki!

First download the nuget package and add the namespace "SimpleHashing".

Getting started

Example of generating a hash with the input "12345":

string hash = PBKDF2.Hash("12345");

Example of verifying a generated hash:

string hash = PBKDF2.Hash("12345");
bool equals = PBKDF2.Verify(hash, "12345");//true
bool equals2 = PBKDF2.Verify(hash, "54321");//false

More advanced

Specify the Iterations of PBKDF2(Default = 50000).
Iterations need to be the same when using Verify and Hash,
else the output will be different and Verify will return false.

string hash = PBKDF2.Hash("12345", 30000);
bool equals = PBKDF2.Verify(hash, "12345", 30000);
//Iterations need to be the same, or Verify will return false.

Specify the length of the hash(Default = 32).
This will not be the length of the output.
The length of the output will be: 16 + length of hash.
Those 16 bytes are used to store the random generated salt.

string hash = PBKDF2.Hash(Input, Length: 60);
string hash2 = PBKDF2.Hash(Input, 3000, 60);//With Iterations 
bool equals = PBKDF2.Verify(hash, Input);//Verify will automaticly detect the length

Example of hashing a byte[]

Works the same as hashing a string, but now the input and output is a byte[].

byte[] input = Encoding.UTF8.GetBytes("12345");

byte[] hash = PBKDF2.Hash(input);
bool equals = PBKDF2.Verify(hash, input);

Overloads of all functions

Overloads of the Hash function:

static string Hash(string input, int iterations = 50000, int length = 32)
static byte[] Hash(byte[] input, int iterations = 50000, int length = 32)

Overloads of the Verify function:

static bool Verify(string hashedInput, string input, int iterations = 50000)
static bool Verify(byte[] hashedInput, byte[] input, int iterations = 50000)

Release Notes

- Moved to .net standard

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.3.1 77 5/23/2019
1.0.2.1 436 4/11/2019
1.0.2 1,149 2/16/2019
1.0.1.2 96 2/15/2019
1.0.1.1 88 2/12/2019