Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Created June 25, 2020 18:19
Show Gist options
  • Save BrunoCaimar/afe3ec98f6cb62549a01973e16c9fce6 to your computer and use it in GitHub Desktop.
Save BrunoCaimar/afe3ec98f6cb62549a01973e16c9fce6 to your computer and use it in GitHub Desktop.
MD5 e SHA256 CheckSum generation
public static string GetMD5Checksum(string input)
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
return BitConverter.ToString(hashBytes).Replace("-", String.Empty);
}
}
public static string GetSha256Checksum(string input)
{
var a = input.ToHashSet();
var sha = new SHA256Managed();
byte[] checksum = sha.ComputeHash(Encoding.ASCII.GetBytes(input));
return BitConverter.ToString(checksum).Replace("-", String.Empty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment