• Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

[C#] Get Hash From File

Elite_Modz

Active Poster
Retired Staff
Active Member
Console ID Poster
Reference:
Code:
using System.Security.Cryptography;
using System.IO;

Get MD5 Code 1:
Code:
#region GetMD5Hash
  public static string GetMD5HashFromFile(string filename)
  {
  using (var md5 = new MD5CryptoServiceProvider())
  {
  var buffer = md5.ComputeHash(File.ReadAllBytes(filename));
  var sb = new StringBuilder();
  for (int i = 0; i < buffer.Length; i++)
  {
  sb.Append(buffer[i].ToString("x2"));
  }
  return sb.ToString();
  }
  } //MessageBox.Show(GetMD5HashFromFile(""));

Get Md5 Code 2:
Code:
#region Computer_Get_MD5
  public static string Computer_Get_File_MD5(string filename)
  {
  using (var md5 = new MD5CryptoServiceProvider())
  {
  var buffer = md5.ComputeHash(File.ReadAllBytes(filename));
  var stringbuilder = new StringBuilder();
  for (int i = 0; i < buffer.Length; i++)
  {
  stringbuilder.Append(buffer[i].ToString("x2"));
  }
  return stringbuilder.ToString();
  }
  }//Computer_Get_File_MD5(filepath\file.txt)
  #endregion
 
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.
      Chat Bot: QM|T_JinX has joined the room.
      Back
      Top