Re: MD5

From: Date: Mon, 12 Mar 2001 21:25:57 +0000
Subject: Re: MD5
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-5990@lists.php.net to get a copy of this message
Hi list and Ben: > I have a string that I want to MD5 (No prizes for guessing its a > password), what I want to do is MD5 two strings (one supplied > by the user, and one by my server) and compare them. How can > I do this? <<snipped the rest>> MD stands for message digest, in brief a fixed length hash based upon the string hashed. It is a one way algorithm and the easiest way to crack it is the same solution is what you are after, i.e. string comparison. Lets take an example; <?php // Initialise variables $my_stored_password=<a pre hashed md5 string>; $the_users_password=<a password entered by the user>; // md5 hash the users password $md5_users_password=md5($the_users_password); // do a hash comparison if($md5_users_password == $my_stored_password): { print "It matches!"; } else: { print "Password comparison failed!"; } endif; ?> Remember, any value hashed by md5 will provide the same result, always. Hope this helps you. If you need any more information, feel free to mail the list or me. Regards Jerry.

« previous php.windows (#5990) next »