Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 401
Mr.V. Avatar asked Aug 27 '12 14:08

Mr.V.


2 Answers

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

like image 157
Daniel A. White Avatar answered Oct 04 '22 07:10

Daniel A. White


Yes. Hashes are one-way. Please use symmetric encryption classes like RijndaelManaged.

Here is a RijndaelSimple class that I am using: http://www.obviex.com/samples/encryption.asp

The cached version of the same link is here: http://webcache.googleusercontent.com/search?q=cache:WyVau-XgIzkJ:www.obviex.com/samples/encryption.asp&hl=en&prmd=imvns&strip=1

like image 43
Gautam Jain Avatar answered Oct 04 '22 08:10

Gautam Jain