Skip to content

Instantly share code, notes, and snippets.

@doskir
Created August 28, 2011 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doskir/1176651 to your computer and use it in GitHub Desktop.
Save doskir/1176651 to your computer and use it in GitHub Desktop.
Hasher
using System;
using System.IO;
using System.Security.Cryptography;
namespace Hasher
{
class Program
{
static void Main(string[] args)
{
if(args.Length != 1)
{
Console.WriteLine("Drop a file on the exe to get the hashes");
return;
}
Console.WriteLine(args[0]);
using(FileStream fs = new FileStream(args[0],FileMode.Open,FileAccess.Read))
{
using (MD5 md5 = new MD5Cng())
{
string md5Hash = BitConverter.ToString(md5.ComputeHash(fs)).Replace("-", "").ToLower();
Console.WriteLine("MD5:{0}", md5Hash);
}
fs.Position = 0;
using (SHA1 sha1 = new SHA1Cng())
{
string sha1Hash = BitConverter.ToString(sha1.ComputeHash(fs)).Replace("-", "").ToLower();
Console.WriteLine("SHA1:{0}", sha1Hash);
}
fs.Position = 0;
using (SHA256 sha256 = new SHA256Cng())
{
string sha256Hash = BitConverter.ToString(sha256.ComputeHash(fs)).Replace("-", "").ToLower();
Console.WriteLine("SHA256:{0}", sha256Hash);
}
}
Console.WriteLine("Done");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment