using System.Security.Cryptography;
private static string HashPassword(string input) {
return SHA.ComputeSHA256Hash(input);
static string sha256(string randomString)
var crypt = new System.Security.Cryptography.SHA256Managed();
var hash = new System.Text.StringBuilder();
Encoding iso = Encoding.GetEncoding("ISO-8859-1");
Encoding utf8 = Encoding.UTF8;
var content = Encoding.UTF8.GetBytes(randomString);
byte[] crypto = crypt.ComputeHash(Encoding.Convert(utf8, iso, content));
foreach (byte theByte in crypto)
hash.Append(theByte.ToString("x2"));
public static byte[] GetHash(string inputString)
using (HashAlgorithm algorithm = SHA256.Create())
return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString));
public static string GetHashString(string inputString)
StringBuilder sb = new StringBuilder();
foreach (byte b in GetHash(inputString))
sb.Append(b.ToString("x2"));
public static void Main() {
string myPassword = @"CA37062670\nCA2505099";
Console.WriteLine("The hashed is: {0} (this is what gets saved to the text file)", HashPassword(myPassword));
Console.WriteLine("The hashed is: {0} (this is what gets saved to the text file)", sha256(myPassword));
Console.WriteLine("The hashed is: {0} (this is what gets saved to the text file)", GetHashString(myPassword));