Search code examples
c#stringhashsha512

SHA512 hash to string in C#


I have code to generate SHA512 from string.

 public static string GetCrypt(string text)
        {
            string hash = "";
            SHA512 alg = SHA512.Create();
            byte[] result = alg.ComputeHash(Encoding.UTF8.GetBytes(text));
            hash = Encoding.UTF8.GetString(result);
            return hash;
        }
    
Now I must convert hash back to string. Any ideas how can it be done? Thank you.


Solution

  • Hashes are 1-way. You can't get it back (easily). you might want actual encryption.