in reply to Re: htaccess through perl without apache
in thread htaccess through perl without apache

Thanks for comments. What salt should i throw at crypt to mimic the htaccess crypt? i'm trying to write a htpasswd file in perl. if the password is birthday. I want to generate the .htpasswd file. so in perl i could say.
#!/usr/bin/perl use strict; my $passw = "birthday"; print crypt($passw,"SALT");
But the output doesn't match the shadow password file. I thought these needed to match. Here's my .htaccess file if it helps.
AuthName "Clients/jtrue" AuthType Basic AuthUserFile /home/latitude38productions/.htpasswd Require valid-user

thanks for reading.

Replies are listed 'Best First'.
Re: Re: Re: htaccess through perl without apache
by jsprat (Curate) on Mar 27, 2003 at 01:16 UTC
    From perldoc -f crypt:
    When verifying an existing encrypted string you should use the encrypted text as the salt (like "crypt($plain, $crypted) eq $crypted"). This allows your code to work with the standard "crypt" and with more exotic implementations.

    Works perfectly with htpasswd.

    Update: Or you could try Apache::Htpasswd.

    $foo = new Apache::Htpasswd({passwdFile => "path-to-file", ReadOnly => 1} ); # Check that a password is correct $pwdFile->htCheckPassword("zog", "password");