Jakub Josef | d8e0429 | 2016-11-28 18:02:27 +0100 | [diff] [blame] | 1 | import hashlib |
2 | import random | ||||
3 | import string | ||||
4 | |||||
5 | def encode_password(password): | ||||
6 | salt = ''.join(random.SystemRandom().choice(string.ascii_letters) | ||||
7 | for i in range(6)) | ||||
8 | hash_ = hashlib.sha256("%s{%s}" % (password, salt)).hexdigest() | ||||
9 | return "%s:%s" % (salt, hash_) |