Modifying .htpasswd from Python?

Steve Holden sholden at holdenweb.com
Mon Jan 22 09:09:29 EST 2001


"Gustaf Liljegren" <gustafl at algonet.se> wrote in message
news:90316137Fgustaflalgonetse at 194.213.69.148...
> michael at stroeder.com (Michael Ströder) wrote:
>
> >Gustaf Liljegren wrote:
> >>
> >> This can be done easily in Perl, using the crypt() function. Now I
> >> need a Python function doing exactly the same encryption as the
> >> htpasswd command.
> >
> >See module crypt.
>
> I saw it, but couldn't import it, and by the docs it seems to be only
> decrypting.
>
Another poster has already told you why you don't find it: it must be
configured in, which doesn't happen by default.

Your assumption about decrypting only is quite wrong, however: only an
encryption function is provided!  This is exactly what you need for both
password entry and checking, since a password (as you probably know) is
verified by checking that, with the same salt, the password provided
encrypts to the same value as was stored when the password was set.

Note also that you should not expect to find crypt on Windows systems since
it relies on the Unix crypt() library routine.

regards
 Steve





More information about the Python-list mailing list