Showing posts with label crypt. Show all posts
Showing posts with label crypt. Show all posts

Saturday, September 11, 2010

python crypt authenticate htpasswd/htdigest

A python snippet to authenticate against a htpasswd hash in Python:
from crypt import crypt
pw = '2600'
htpasswd = 'Jywn1PBEdYjkg'
authd = crypt(pw,htpasswd)==htpasswd
assert authd
authd = crypt('wrongpw',htpasswd)==htpasswd
assert authd==False