Created
October 4, 2013 22:29
-
-
Save murilobsd/6833904 to your computer and use it in GitHub Desktop.
Simples função para gerar as hashs do url. >>> import urlhash
>>> print pkgen()
ljq4vvlxhotnoydkqziwycslvbiwxlxz
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 base64 import b32encode | |
from hashlib import sha1 | |
from random import random | |
def pkgen(): | |
rude = ('lol',) | |
bad_pk = True | |
while bad_pk: | |
pk = b32encode(sha1(str(random())).digest()).lower()[:32] | |
bad_pk = False | |
for rw in rude: | |
if pk.find(rw) >= 0: bad_pk = True | |
return pk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment