Generate SHA1 checksum of a file function

suggest change

Add references to the System.Security.Cryptography and System.IO namespaces. BitConverter.ToString returns uppercase hex with dashes (AA-BB-...), not a continuous hex string.

public string GetSha1Hash(string filePath)
{
    using (FileStream fs = File.OpenRead(filePath))
    using (SHA1 sha = new SHA1Managed())
    {
        return BitConverter.ToString(sha.ComputeHash(fs));
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents