Skip to content

Instantly share code, notes, and snippets.

@k0d
Created April 15, 2012 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save k0d/2394453 to your computer and use it in GitHub Desktop.
Save k0d/2394453 to your computer and use it in GitHub Desktop.
htpasswd check
import crypt
def check(username, password):
data = f.read().split("\n")
for line in data:
if line.startswith(username + ':'):
foundUser = line
break
user, t, salt, hashed = foundUser.split('$')
return crypt.crypt(password, '$6$%s$' % salt) == '$6$%s$%s' % (salt, hashed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment