feat: 支持平台关联算法,支持AIX改密

This commit is contained in:
jiangweidong
2022-04-15 14:39:37 +08:00
committed by 老广
parent 031077c298
commit 5e70a8af15
3 changed files with 37 additions and 12 deletions

View File

@@ -186,10 +186,27 @@ def make_signature(access_key_secret, date=None):
return content_md5(data)
def encrypt_password(password, salt=None):
from passlib.hash import sha512_crypt
if password:
def encrypt_password(password, salt=None, algorithm='sha512'):
from passlib.hash import sha512_crypt, des_crypt
def sha512():
return sha512_crypt.using(rounds=5000).hash(password, salt=salt)
def des():
return des_crypt.hash(password, salt=salt[:2])
support_algorithm = {
'sha512': sha512, 'des': des
}
if isinstance(algorithm, str):
algorithm = algorithm.lower()
if algorithm not in support_algorithm.keys():
algorithm = 'sha512'
if password and support_algorithm[algorithm]:
return support_algorithm[algorithm]()
return None