MD5 Hashing Comparison

From: Date: Sat, 20 Nov 2004 22:49:04 +0000
Subject: MD5 Hashing Comparison
Groups: php.general 
Request: Send a blank email to php-general+get-202583@lists.php.net to get a copy of this message
Hi, I'm trying to write a md5 hash to auth users... And before I get flamed about md5 not being a crypt system but a hashing system I know... Security is not a problem.. I'm trying to build a standalone Message Update Center intranet with PHP The problem I'm having is comparing a user inputed word or passphrase and comparing the code to the hash on a mysql database.... here's the code.... <?php // connect to database $connection = mysql_connect("localhost","root"); mysql_select_db("forum"); $result = mysql_query('Select username, password from users'); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // start while fetch loop if($_POST['givenuser'] == $row['username']) { // Begin user check if( md5($_POST['givenpassword']) == $row['password'] ) print("Welcome!"); // The problem I'm having is the comaprisons are not accurate..... // If I display ---> print(md5($_POST['givenpassword']); // and $row['password'] to the browser all 32 char are identical } // end user check } // end while fetch loop ?> Any Ideas at all? I was thinking that there could be somesort of WHITESPACE problem in the hashing of the passed var givenpassword or possible a problem with a wierd floting point calculation at the comparision level? thanks in advance

« previous php.general (#202583) next »