faqts : Computers : Programming : Languages : PHP : Common Problems : Encryption

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

38 of 60 people (63%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I check the user input password from a form with encrypted one in the Apache htpasswd file?

May 4th, 2000 12:57
Russell Speed, Nikhil Mehta, Nathan Wallace, Carlos Azevedos


The first two characters of the password are the "salt" to be passed
to crypt.  So the following snippet should result in an equivalently
encrypted password for string comparision.
$salt=substr($Password_From_Passwd_File,0,2);
$pass=crypt( $Password_From_Form,$salt );
if( strcmp( $pass, $Password_From_Passwd_File )  )
      // Fail authentication.