Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to decode md5

Status
Not open for further replies.

torkil

Technical User
Aug 27, 2001
3
DK
Hi there!

A quick question.
if I encode a string with md5 like this:

$string = "Hello World!";
$encoded_string = md5($string);
$decoded_string = ?????

How do I decode $encoded_string??

 
MD5 is not a decodable algorithm (often regarded to as one-way). The only way to decode it is to throw messages in the algorithm to see if one of them generates the same hash -- pretty unlikely. It's application is primarily for verification of messages (or downloads as seen later). We'll use the classical entities Alice, Bob and Eve:

Alice writes a message. She then creates an MD5 hash of the message. She posts the MD5 on her website for public viewing. She then sends Bob the message.

Bob receives the message and, being wary of the fact that it could have been intercepted mid-transmission, creates an MD5 hash of it. He compares this hash with the one on Alice's website. It matches, so Bob knows that it came from Alice without tampering.

Had Eve captured the message and put her own scribblings in there, the MD5 would have been completely different and the tampering obvious. It is nearly impossible to come up with text that create the same hash *and* look legitimate.

This applies more to binary files than e-mails of course... Binary files can contain viruses, trojan horses, etc., and it's nearly impossible to tell just by looking at them. So often application developers will place MD5 hashes on their websites so you can compare your downloads.

By no means a quick question, but I hope this helps.

brendanc@icehouse.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top