Created
April 15, 2012 19:37
-
-
Save k0d/2394453 to your computer and use it in GitHub Desktop.
htpasswd check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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