Python htpasswd
From wikinotes
Python library for managing user authentication. See htpasswd for notes.
NOTE:
Most systems that use htpasswd use the C crypt library to compare password hashes. Crypt's algorithms are not universal. If you need to generate a crypt hash for a different OS, try python passlib .
Documentation
official docs | https://github.com/thesharp/htpasswd |
my fork (adds more encryption types, more ackward than needs to be...) | https://github.com/willjp/htpasswd |
Usage
import htpasswd with htpasswd.Basic('/path/htpasswd', mode='bcrypt') as userdb: userdb.add('will', 'password') if 'will' in userdb: # check # validate password hashpw = userdb.initial_users['will'] is_valid = bcrypt.checkpw(password, hashpw)