Verify Hex Hash, Base64 Hash, Byte Hash : Hash : Security C# Source Code


Custom Search

C# Source Code » Security » Hash »

 

Verify Hex Hash, Base64 Hash, Byte Hash








    
 


using System;
using System.Text;

class MainClass {
    public static bool VerifyHexHash(byte[] hash, string oldHashString) {
        StringBuilder newHashString = new StringBuilder(hash.Length);

        foreach (byte b in hash) {
            newHashString.AppendFormat("{0:X2}", b);
        }

        return (oldHashString == newHashString.ToString());
    }

    private static bool VerifyB64Hash(byte[] hash, string oldHashString) {
        string newHashString = Convert.ToBase64String(hash);
        return (oldHashString == newHashString);
    }
    private static bool VerifyByteHash(byte[] hash, byte[] oldHash) {
        if (hash == null || oldHash == null || hash.Length != oldHash.Length)
            return false;

        for (int count = 0; count < hash.Length; count++) {
            if (hash[count] != oldHash[count]) return false;
        }

        return true;
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Security
» Hash