using System.Security.Cryptography;
public static byte[] StringToByteArray(String hex)
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
public static string ByteArrayToString(byte[] ba)
StringBuilder hex = new StringBuilder(ba.Length * 2);
hex.AppendFormat("{0:x2}", b);
public static void Main()
Console.WriteLine("Expected:");
Console.WriteLine("740f81cd7deed90102a36e41a74cbe7373856ff647c66d0c945db8c4dfc67130");
string input = "d8818b38a14e7461e87301ad4b9809b558bcbca816b650cd470452e018ada255";
var serverSeed = StringToByteArray(input);
Console.WriteLine("Server Seed:");
Console.WriteLine(ByteArrayToString(serverSeed));
using (var sha = SHA256.Create())
var hash = sha.ComputeHash(Encoding.ASCII.GetBytes(input));
Console.WriteLine("Actual:");
Console.WriteLine(ByteArrayToString(hash));
Console.WriteLine("Input in ASCII encoding:");
Console.WriteLine(ByteArrayToString(Encoding.ASCII.GetBytes(input)));