This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
M2OLA/backend/app/utils.py
Clément ARNAUDEAU ed0f2b1808 TG-35 : Typo
2017-01-23 15:54:16 +01:00

16 lines
343 B
Python

import random
import string
from hashlib import sha512
SIMPLE_CHARS = string.ascii_letters + string.digits
def get_random_string(length=32):
return ''.join(random.choice(SIMPLE_CHARS) for i in range(length))
def get_random_hash(length=64):
hash = sha512()
hash.update(get_random_string())
return hash.hexdigest()[:length]