Do not override secret key...

This commit is contained in:
Antoine Nguyen
2017-08-01 18:27:23 +02:00
parent ea8b4e8afa
commit 1c3c28427e
2 changed files with 22 additions and 0 deletions

View File

@@ -208,3 +208,17 @@ def convert_version_to_int(version):
number += num << total_bits
total_bits += bits
return number
def random_key(l=16):
"""Generate a random key.
:param integer l: the key's length
:return: a string
"""
punctuation = """!#$%&()*+,-./:;<=>?@[]^_`{|}~"""
population = string.digits + string.ascii_letters + punctuation
while True:
key = "".join(random.sample(population * l, l))
if len(key) == l:
return key