Solved

unhashing the hashed string.(decrypt)

Posted on 2004-10-13
8
1,106 Views
Last Modified: 2009-12-16
hi all
I am encoding the password to be inserted in the database using following piece of code.
------------------------------------------------------------------------------------------------------------------
     Dim oEncoder As UTF8Encoding
            Dim oMD5Hasher As MD5CryptoServiceProvider
 
            Dim byteHashedPassword As Byte()
 
            oMD5Hasher = New MD5CryptoServiceProvider
            oEncoder = New UTF8Encoding
            byteHashedPassword = oMD5Hasher.ComputeHash(oEncoder.GetBytes(sPassword & sUserName.ToLower))
'i insert bytehashedpassword in the db in password field which is of datatype binary
----------------------------------------------------------------------------------------------------------------
I have problem decrypting it.

Can somebody help me. I again want to decrypt(unhash) it to string from binary.

Thank you in advance
 
With Best Regards
Vivek Phadke
0
Comment
Question by:vicky_phadke
  • 5
8 Comments
 
LVL 14

Accepted Solution

by:
AvonWyss earned 500 total points
Comment Utility
You cannot unhash a hash. That would defeat it's purpose. The hash is a value which is different with a very high probability for each different string, so that the hash can be used as identifier for that given string. But you shall not be able to revert the hashing process, especially not MD5 and other cryptographic-grade hashes.

But what you can do is hash the password you've received with the same method and then compare the two hashes. If they are identical, you can safely assume that the passwords entered were equal.

The only way to "unhash" is by brute force attack, e.g. try every possible solution, hash it, and see if the hash is the one you were looking for. But this is not practical for longer and secure passwords (e.g. containing at least a digit and some special char like ,.-_* as well as both upper-and lowercase chars, with a length of 8 minimum).
0
 

Author Comment

by:vicky_phadke
Comment Utility
So there is no way i can unhash it?
Well I am diong the forget password thing. I need to send the user his forgotten password. Although i can generate a new password and give it to him. But then the basic need of unhashing would be defeated. What i feel is the thing that is encrypted can be decrypted provided we have all the keys.
0
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
Well, hashing is NOT encrypting, but hashing. These are different things! If you want to encrypt it, there are also asymmetric and symmetric encryption algorithms contained in the .NET framework, which then can be used to decrypt it again. But the HASH is not an encryption!
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
Hashes are used for the verification of values. A hash has a fixed size (for instance, MD5 and SHA1 are 16 bytes AFAIR), independently of the size of the contents hashed. You can hash hundreds of GB into the 16 byte hash! Now, given that you hashed anything large, how would you expect to recover the original contents from the 16 bytes of the hash? It's not possible, or it would happen to be the perfect packing alogrithm *g*...

The point is that these 16 bytes of the hash are very very very very unlikely the same for any two hashed values. If you change one bit, or swap two bytes in the data you're hashing, you get a completely different hash, which does not look anything like the one of the unchanged contents. This means that even slight changes in the contents are reflected in the hash, but the changed hash gives you no clue how much and what has changed in the contents.

So, there is NO unhashing. Hashing is NOT an encryption, but a means to verify data integrity or data equality of an arbitrary amount of data. If you tamper with the data, the hash immediately becomes invalid. That's what a hash is made for.
0
 
LVL 4

Expert Comment

by:Farshid-Zaker
Comment Utility
Hash algorithm like MD5 or SHA4 have not reverse solutions. If you want to regenerate password from encrypted value, you should use other encryption algorithms.

Farshid
0
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
My comments accurately answered the questions asked.
0
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
vicky_phadke, what did you miss to give an A grade? What could I have done better? Thank you fro your feedback, so that I can give better comments in the future.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now