HashingHelper - Aghyad-Khlefawi/Coddee GitHub Wiki

A static class containing a helper functions for hashing data.

Methods

Name Description
HashedValue(string,string,HashAlgorithm) Compute the hash value of a provided string
HashedValue(string,HashAlgorithm) Compute the hash value of a provided string
GenerateRandomSalt(RNGCryptoServiceProvider,int) Generate a random salt for the hashing
ValidateHash(string,string,string,HashAlgorithm) Compares a hash to a plain text by hashing the plain text an comparing the hashes
ValidateHashString64(string,string,string,HashAlgorithm) Validate a hash in Base64 format

C# Example:

string myPassword = "VERYSTRONGPASSWORD";
HashedValue hashedPassword = HashHelper.GenerateHash(myPassword);
Debug.WriteLine(hashedPassword.Hash); //outputs: b@?????v?????0??j_?2M?(3I?O?&?
var isValid = HashHelper.ValidateHash(myPassword, hashedPassword.Salt, hashedPassword.Hash);
Console.WriteLine(isValid); //outputs: true