using System.Security.Cryptography;
public class HashingUtils
public static string BytesTohexString(byte[] bytes)
if (bytes == null || bytes.Length < 1)
int count = bytes.Length;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < count; i++)
string tempHex = Convert.ToString(bytes[i], 16);
builder.Append(tempHex.Length == 1 ? "0" + tempHex : tempHex);
return builder.ToString();
public static string HashingWithSHA256(string input)
SHA256 sha256 = new SHA256CryptoServiceProvider();
byte[] source = Encoding.Default.GetBytes(input);
byte[] crypto = sha256.ComputeHash(source);
string result = BytesTohexString(crypto);
public static void Main(string[] args)
string result = HashingUtils.HashingWithSHA256("ICCardNo");
Console.WriteLine("Encrypted result: " + result);