View Full Version : Emulating Apache's htpasswd utility
filburt1
Wed 2nd Oct '02, 12:03am
I want to write a PHP script that can generate .htaccess files to use for authentication. I looked up the man page for Apache and it says that on Windows the default flag is set for using a "modified" MD5 algorithm to generate the password hash. Anybody know how to do this in PHP?
Chen
Wed 2nd Oct '02, 10:50am
crypt()...
filburt1
Wed 2nd Oct '02, 11:02am
'Kay, I thought it would be md5 with some manipulation. :)
Will a hash generated by crypt() work on both Windows and Unix Apache?
Chen
Wed 2nd Oct '02, 11:06am
Originally posted by filburt1
'Kay, I thought it would be md5 with some manipulation. :)
Will a hash generated by crypt() work on both Windows and Unix Apache?
Yes.
filburt1
Wed 2nd Oct '02, 12:28pm
Awesome, thanks Chen :)
filburt1
Wed 2nd Oct '02, 4:18pm
'Kay, not working. htpasswd in Windows generates this when I type "password":
Automatically using MD5 format on Windows.
New password: ********
Re-type new password: ********
filburt1:$apr1$eR3.....$OGThTZOzEE7JZmkqxJQt.0
crypt generates this:
filburt1:t.KEawYVJvlSA
filburt1
Fri 4th Oct '02, 10:33am
Chen? :)
Chen
Fri 4th Oct '02, 10:47am
Sorry. Have you checked the PHP docs for the crypt() function?
filburt1
Fri 4th Oct '02, 12:24pm
Yup, specifically the user comments about crypt() and .htaccess and none of them helped. :(
filburt1
Sat 5th Oct '02, 4:05pm
Looks like I'll just end up exec'ing htpasswd...
MUG
Sat 5th Oct '02, 4:13pm
crypt() will output something different every time... (it uses a random 'salt')
edit: Yes, I know you can specify the salt yourself but that isn't a good idea...
vBulletin® v3.8.0 Beta 3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.