Little idea for a code to associate to a user

#!/usr/bin/env python
#
# Author: Luca Francesca
# A function for key generation
#

import random
import string

def keyGen(uname, pwd):
key = random.choice(string.lowercase)
key += uname[1:4]
key += pwd[2:4] + random.choice(string.uppercase)
key += random.choice(string.lowercase)
key += str(random.randint(2,9))
key += str(random.randrange(1,10) * 3)
key += random.choice(string.uppercase)
key += random.choice(string.lowercase)
key += str(random.randint(random.randint(1,50) ,random.randint(50,70)))
return key;

if __name__ == ‘__main__’:
print keyGen(‘luca’, ‘luca’)
print keyGen(‘marco’, ‘marco’)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s