How to get the original string from a HashCode byte[]?

  • Thread starter Thread starter gg
  • Start date Start date
G

gg

Hi, Dear All,
Please see the following code:

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHash( Encoding.Unicode.GetBytes( str) );
.....

I want to know how to get the original str -"1234" from m_str?

Thanks
 
gg said:
Hi, Dear All,
Please see the following code:

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHash( Encoding.Unicode.GetBytes( str) );
....

I want to know how to get the original str -"1234" from m_str?

Thanks


Can't be done. If you want the original string, don't use a hash function.
Use private key encryption.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
gg said:
Please see the following code:

SHA1 sha1 = SHA1.Create();
string str="1234";
byte[] m_str = sha1.ComputeHash( Encoding.Unicode.GetBytes( str) );
....

I want to know how to get the original str -"1234" from m_str?

Hashing is particularly designed to be a one-way process. If you want a
two-way process, look at the various symmetric or asymmetric
encryption/decryption algorithms in the System.Security.Cryptography
space.
 
Back
Top