php - How do I effectively use crypt() -


i don't understand documentation @ php.net. appears using encrypted version of password salt when testing against original encryption.

when insert crypt out optional second parameter (the salt) different encrypted versions of same password. expected behavior?

however if insert second parameter of 'd4' same encrypted passwords same password input. expected behavior.

prior insertion on signup:

$pass = crypt('$pass', 'd4'); // after insert $pass mysql table 

testing on signin:

$pass = crypt($pass, 'd4'); // after test $pass against mysql table 

php.net documentation:

<?php $password = crypt('mypassword'); // let salt automatically generated  /* should pass entire results of crypt() salt comparing    password, avoid problems when different hashing algorithms used. (as    says above, standard des-based password hashing uses 2-character salt,    md5-based hashing uses 12.) */ if (crypt($user_input, $password) == $password) {    echo "password verified!"; } ?>  

how work?

since crypt() uses first 2 characters (or whatever crypt_salt_length is) of salt argument, passing in encrypted password (of first characters salt used encrypt it) right thing.

if no salt argument passed in, random salt generated , used.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -