Skip to content

Instantly share code, notes, and snippets.

@gabrielcesar
Created December 5, 2013 16:02
Show Gist options
  • Save gabrielcesar/7808034 to your computer and use it in GitHub Desktop.
Save gabrielcesar/7808034 to your computer and use it in GitHub Desktop.
Function in Python to create a HASH by using numbers and letters.
def hash ( length ):
'''
2013 Gabriel Cesar
created_at 20131018
last_update 20131018
Exemplo de uso: hash ( 16 )
Retorno: 142y96c876C2933b
'''
s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
t = ''
for i in range ( length ):
t += s[random.randrange ( len ( s ))]
return t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment