Created
January 30, 2014 22:36
-
-
Save tonetheman/8721558 to your computer and use it in GitHub Desktop.
testing passlib http://pythonhosted.org/passlib/index.html
This file contains 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
from passlib.context import CryptContext | |
pwd_context = CryptContext( | |
schemes = ["sha512_crypt"], | |
default = "sha512_crypt", | |
all__vary_rounds = 0.1, | |
pbkdf2_sha256__default_rounds = 8000, | |
) | |
def make_some_hash(): | |
hash1 = pwd_context.encrypt("a") | |
hash2 = pwd_context.encrypt("b") | |
hash3 = pwd_context.encrypt("a") | |
print hash1 | |
print hash2 | |
print hash3 | |
return (hash1,hash2,hash3) | |
def writeout(hash1,hash2,hash3): | |
outf = open("hashes.txt", "w") | |
outf.write(hash1) | |
outf.write("\n") | |
outf.write(hash2) | |
outf.write("\n") | |
outf.write(hash3) | |
outf.write("\n") | |
outf.close() | |
def readin(): | |
inf = open("hashes.txt", "r") | |
data = inf.read() | |
inf.close() | |
return data | |
def verify_data(): | |
data = readin() | |
data = data.split() | |
import string | |
data = map(string.strip,data) | |
print data | |
print pwd_context.verify("a", data[0]) | |
print pwd_context.verify("a", data[1]) | |
print pwd_context.verify("a", data[2]) | |
def test_writing(): | |
(a,b,c) = make_some_hash() | |
writeout(a,b,c) | |
verify_data() | |
test_writing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment