code: def generate_hash(self, length=30):
          
          import random, string
          chars = string.ascii_letters + string.digits
          ran = random.SystemRandom().choice
          hash = ''.join(ran(chars) for i in range(length))
          return hash
docs: Generate random string of given length