def get_rand_string(length=<NUM_LIT:12>, allowed_chars='<STR_LIT>'):
if not using_sysrandom:<EOL><INDENT>random.seed(<EOL>hashlib.sha256(<EOL>("<STR_LIT>" % (<EOL>random.getstate(),<EOL>time.time())).encode('<STR_LIT:utf-8>')<EOL>).digest())<EOL><DEDENT>return '<STR_LIT>'.join([random.choice(allowed_chars) for i in range(length)])<EOL>
Returns a securely generated random string. Taken from the Django project

The default length of 12 with the a-z, A-Z, 0-9 character set returns
a 71-bit value. log_2((26+26+10)^12) =~ 71 bits