using System.Security.Cryptography;
public static void Main()
Console.WriteLine(Snippets.SHA1Util.SHA1HashStringForUTF8String("ChangeMe!").ToUpper());
public static class SHA1Util
public static string SHA1HashStringForUTF8String(string s)
byte[] bytes = Encoding.UTF8.GetBytes(s);
using(var sha1 = SHA1.Create())
byte[] hashBytes = sha1.ComputeHash(bytes);
return HexStringFromBytes(hashBytes);
public static string HexStringFromBytes(byte[] bytes)
var sb = new StringBuilder();
foreach (byte b in bytes)
var hex = b.ToString("x2");