bcrypt - crypt password storage and retrival php -


i trying set secure login & register system using crypt() have read that php's stored function bcrypt

i registering user taking password , and crypting it.

$hashed_password = crypt($mypassword); 

i store $hashed_password in db

then when user logs in trying match password whats stored.

i found function on php.net cant work

$password stored crypted password , $mypassword users input

if ($password == crypt($mypassword, $password)) {     echo "success! valid password"; } 

i understand crypt generates unique hash each time called dont understand how function can work.

am completeley missing point read crypt() 1 function , decrypt not exist?

any appreciated in not showing error of ways in completing secure login

you're using second parameter in crypt() call, it's treated salt. compare properly, can use:

if ($password == crypt($mypassword))  {     echo "success! valid password"; } 

but php provides native functionality hashing routines - introduced if 5.5 version , called password hashing.

for php versions below 5.5 down 5.3.7, there backported compatibility function same: https://github.com/ircmaxell/password_compat include , use it.

but note have read hashed password database , compare php. cannot query database newly created password hash find user.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -