using System.Security.Cryptography;
public static void Main()
Console.WriteLine("Enter the plain text password : \n");
string plainTextPassword = Console.ReadLine();
string Sha512Hash = GetSHA512Hash(plainTextPassword);
string Sha512HashAsHex = GetSHA512HashAsHex(plainTextPassword);
Console.WriteLine("SHA512 hash bytes encoded as string " + Sha512Hash);
Console.WriteLine("SHA512 hash bytes encoded as Hex " + Sha512HashAsHex);
Console.WriteLine("SHA512 hash bytes back to original " + GetSHA512HashAsOriginal(Sha512Hash));
static string GetSHA512Hash(string message)
using (var sha512 = SHA512.Create())
byte[] hashedBytes = sha512.ComputeHash(Encoding.UTF8.GetBytes(message));
return Encoding.UTF8.GetString(hashedBytes);
static string GetSHA512HashAsHex(string message)
using (var sha512 = SHA512.Create())
byte[] hashedBytes = sha512.ComputeHash(Encoding.UTF8.GetBytes(message));
return BitConverter.ToString(hashedBytes).Replace("-", "");
static string GetSHA512HashAsOriginal(string message)
byte[] hashAsBytes = Encoding.UTF8.GetBytes(message);
return BitConverter.ToString(hashAsBytes).Replace("-", "");