CSharp · Console
using System;
using System.Security.Cryptography;
using System.Text;
public class Program
{
public static void Main()
{
//Console.WriteLine("Hello World");
HashSh1("Technology");
}
static string HashSh1(string input)
{
using (SHA1Managed sha1 = new SHA1Managed())
{
var hashSh1 = sha1.ComputeHash(Encoding.UTF8.GetBytes(input));
// declare stringbuilder
var sb = new StringBuilder(hashSh1.Length * 2);
// computing hashSh1
foreach (byte b in hashSh1)
{
// "x2"
sb.Append(b.ToString("X2").ToLower());
}
// final output
Console.WriteLine(string.Format("The SHA1 hash of {0} is: {1}",input,sb.ToString()));
return sb.ToString();
}
}
}