Generate SHA1 checksum of a file function
suggest changeAdd 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));
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents