RE: [PHP] problems with md5()

From: Date: Thu, 08 Apr 2004 04:59:38 +0000
Subject: RE: [PHP] problems with md5()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-182783@lists.php.net to get a copy of this message
The second, longer, one is the correct one. It looks like the column you've got the password stored in is too small, it must be 32 characters long Chris -----Original Message----- From: jdavis [mailto:jd@taproot.bz] Sent: Wednesday, April 07, 2004 9:36 PM To: PHP List Subject: [PHP] problems with md5() hello, I have a database containing usernames and md5 encrypted passwords. When i use md5() to encrypt a users password recived via a form to compare to the md5ed passwd in the database i get problems... for instance ... user foo has passwd 'pass' 'pass' md5ed in database is this 1a1dc91c907325c69271ddf0c i got this using phps md5. Then ... when i md5 a pass i recieve later to compare for a login the password 'pass' comes up like this... 1a1dc91c907325c69271ddf0c944bc72 they are the same except the trailing 944bc72 this happens when i try other password too. here is the code that is giving me the problems... function auth(){ $user = $_POST['user']; $pass = rtrim($_POST['pass']); // i added this trying to fix :( $pass = md5($pass); $query = "select password from dealers where username = '$user'"; $result = $this->sqlQuery($query); if(!$result){ echo "Sorry there was a error, please try again later.\n"; } else{ $thePass = mysql_fetch_array($result); if($thePass[0]){ if(strcmp( $pass , $thePass[0]) == 0){ echo "match\n"; } else{ echo "pass = $pass <br>"; // from from echo "hash = $thePass[0]"; // from db } } else{ $this->logonPage(1); } } } can some one tell me what im doing wrong thanks, jd@taproot.bz "Bad spellers of the world untie!" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#182783) next »