1 import string
2 import random
3
4 def gen_key(no_of_chars):
5 allowed_chars = string.digits+string.uppercase
6 return ''.join([random.choice(allowed_chars) for i in range(no_of_chars)])