Created
August 28, 2011 13:14
-
-
Save doskir/1176651 to your computer and use it in GitHub Desktop.
Hasher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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