1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00
This commit is contained in:
Óscar García Amor 2017-08-07 11:31:15 +02:00
parent a6a37475c2
commit 9818117b46

View File

@ -142,17 +142,14 @@ class UserManager:
def __encrypt_password(password, salt = None): def __encrypt_password(password, salt = None):
if salt is None: if salt is None:
salt = ''.join(random.choice(string.printable.strip()) for i in xrange(6)) salt = ''.join(random.choice(string.printable.strip()) for i in xrange(6))
return hashlib.sha1(salt + password).hexdigest(), salt return hashlib.sha1(salt.encode('utf-8') + password.encode('utf-8')).hexdigest(), salt
@staticmethod @staticmethod
def __decode_password(password): def __decode_password(password):
if not password.startswith('enc:'): if not password.startswith('enc:'):
return password return password
enc = password[4:] try:
ret = '' return binascii.unhexlify(password[4:])
while enc: except:
ret = ret + chr(int(enc[:2], 16)) return password
enc = enc[2:]
return ret