Hi,

i restart a post that start on the same forum with olaf on november 2003

http://www.phpbuilder.com/board/showthread.php?threadid=10259211

When you use PHP, to create the file .htpasswd and crypt your password with the crypt function, it doesn't use the same algorithm (MD5 under windows) like "htpasswd.exe"

Eg:
If I crypt the password "Mypwd" for the user admin

htpasswd.exe -n -b admin MyPwd
Automatically using MD5 format on Windows.
admin:$apr1$B5/.....$STWipQ3db3mx5yzyPUuN01

From the crypt function in PHP, I obtain
$1$pR0.8A0.$ZX5QLoVk9xbNtQ/ljY8rn0 for the same password.

Does anyone solves this problem ?

Thanks

Christopher

    2 years later

    In reply user cgirard post on 02-09-2004 08:36 AM
    I am having the same problem. When I use the Apache commands on the command line to write a username and password to the file .htpasswd a username and password of the type:
    admin:$apr1$B5/.....$STWipQ3db3mx5yzyPUuN01
    is created exactly as cgirard is seeing. Additionally when I then access the protected area and enter the username and password I gain access successfully. I have written a PHP application that attempts to manage user accounts. This script successfully displays all of the users in .htpasswd. I can also enter in users and passwords into the .htpasswd file. Originally I used the crypt() function in the PHP application. This did successfully write the username and entered password to the file. However because the encryption of this entry is different then that used by Apache on a win32 system I fail to gain entry into the protected area when trying to access via the web using the password generated using the PHP application . To date I have not successfully created a username and password via my PHP application. I would greatly appreciate help on this. There is a function in PHP md5() I could use something like this:
    $hash = md5($salt . $password);

    That is if this is the encryption that Apache uses on a Win32 system. I will give it a try and let you know what I find.

    Respectfully
    SirChristopher

      Write a Reply...