Skip to content

Instantly share code, notes, and snippets.

@mbr
Created June 9, 2012 12:13
Show Gist options
  • Save mbr/2900770 to your computer and use it in GitHub Desktop.
Save mbr/2900770 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# coding=utf8
from binascii import hexlify
import os
from passlib.hash import bcrypt
dummy = bcrypt(use_defaults=True)
salt = dummy.salt
print "salt", salt
h = bcrypt(salt=salt, use_defaults=True)
msg = hexlify(os.urandom(36))
data = ['foo', 'bar', msg, msg+'xx']
print "EQUAL", h.encrypt(msg, salt=salt) == h.encrypt(msg + 'xx', salt=salt)
#for i in data:
# print "h.encrypt(%r, salt=%r) => %r" % (i, salt, h.encrypt(i, salt=salt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment