Skip to content

Instantly share code, notes, and snippets.

@murilobsd
Created October 4, 2013 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save murilobsd/6833904 to your computer and use it in GitHub Desktop.
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
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