Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htpasswd perl script

Status
Not open for further replies.

ArcAnjel

Programmer
Feb 9, 2005
13
US
Hello all,

I am trying to write a very simple password program (it isn't being used for any important data) that uses the .htpasswd file (so I don't have to maintain two password files for users). So I need a way to convert the password the user types in into the .htpasswd hash either before it is sent to the perl script (probably using javascript) or, my preference, in the perl script after the arrival of the password (in case someone have JS disabled or something).

Please correct me if I am wrong, but I think .htpasswd uses an MD5 hash, but to my knowledge, my ISP does not use any of the standard MD5 perl modules. At least, non of my code has worked so far.

Again, this is not for any critical/personal data, I am aware of the limitations of this scheme.

Thanks
 
Thanks for the suggestion, but it didn't work.

I'm tired of looking for this. I am just going to make another password database.
 
Thanks for not letting me give up on this.
It wasn't working because of a binary transfer. Yeah, yeah go ahead and laugh, I deserve it...

If anyone is curious or wants to criticize it, here is my script below:

#!/usr/local/bin/perl

require "cgi-lib.pl";
$PASS = '/.Admin/.htpasswd';
$valid = "false";

&ReadParse(*input);
$in_id = $input{ID};
$in_pass = $input{PASS};

open(PASS, "$PASS");
while(<PASS>) {
chomp;
($user, $pass) = split(/:/, $_);
if($user eq $in_id) {
if(crypt($in_pass,$pass) eq $pass) {
$valid = "true";
}
}
}
close(PASS);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top