Skip to content

Instantly share code, notes, and snippets.

@mishrsud
Created August 3, 2015 06:16
Show Gist options
  • Save mishrsud/bf26eebf7cfeb0fa0590 to your computer and use it in GitHub Desktop.
Save mishrsud/bf26eebf7cfeb0fa0590 to your computer and use it in GitHub Desktop.
void Main()
{
var fileName = @"C:\OfficeDocs\somfile.js";
var hash = GetFileHash(fileName);
hash.Dump("Hash");
}
// Define other methods and classes here
public static string GetFileHash(string filePath)
{
using (FileStream stream = File.OpenRead(filePath))
{
var sha = new SHA256CryptoServiceProvider();
byte[] hash = sha.ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", String.Empty);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment