hash - PHP crypt() always failing? -


i'm quite new encryption , passwords , on, , have suspect code here seems failing. create new user , insert password mysql. password inserted output of

crypt( $user_input ); 

when retrieve row , run following code verify user can log in, returns false (and yes, user inputting correct password). works on windows machine not on ubuntu - user has been created on ubuntu. there overlooking?

while( $row = $result->fetch_object() ) {    error_log("before crypt"); if( crypt( $password, $row->password) == $row->password ) {     error_log("crypt works!" );     return true; } else {     error_log("crypt fails!");     return false; } } 

edit: i've done logging, , here's get:

ouput crypt( $password ) is: $6$1ysegqi5$x9t7cz4fxjjurecu2vqf0klby5kwqkb8lliik9oq4rd4.w.1/iwmzw7/xaqdxiv8owwspmlmvi.kafgsbxelz1

the hash stored in mysql is:

$6$/ryc6gax$unhuzqpdmjy29dgub06ilv4oh69d5h7nfnbsw1

they aren't same. what's going on!?

i have found answer, although took me while realize it. benefit of else runs problem...check size of column storing hash in database!

the code written on windows system, when ran on linux system (ubuntu) crypt() function using sha-512 algorithm needed longer column length. changed column char(128) in mysql , bingo, worked!!!


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -