Skip to content

Instantly share code, notes, and snippets.

@kylelk
Created January 20, 2014 19:23
Show Gist options
  • Save kylelk/8527280 to your computer and use it in GitHub Desktop.
Save kylelk/8527280 to your computer and use it in GitHub Desktop.
from os import urandom
from hashlib import sha1
import time
def mint(name, bits):
t = time.strftime("%y%m%d")
out = " "
count = 0
while out[:bits] != bits*"0":
RandomData = urandom(8).encode("base64").replace("\n", "")
data = "1:%d:%s:%s::%s:%s"%(bits, t, name, RandomData, format(count, 'x'))
out = (''.join(format(ord(x), '08b') for x in sha1(data).digest()))
count += 1
return data
print mint("email_address", 16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment