SHA512 hash for string in C #

I have code to generate SHA512 from a 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 have to convert the hash back to string. Any ideas how to do this? Thanks.
+7
source share
3 answers

One-time hashes. You cannot return it (easily). you may need actual encryption.

+31
source

Yes. Hashes are one-way. Use symmetric encryption classes such as RijndaelManaged.

Here is the RijndaelSimple class that I use: http://www.obviex.com/samples/encryption.asp

A 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

+1
source

You cannot convert hash back to the string from which you calculated the hash.

If you want this, you need to compare the hash with each hash of the target string.

If one of them matches a hash, then this hash comes from the target string.

Use: If you want to store passwords in a database , you can store your hashes instead of passwords. So even if a hacker gains access to your database, he cannot get a password because he hashed. The only way to find out the line through which we created the hash is to match with the desired line!

0
source

All Articles