import hashlib,base64
# md5加密
s = '123'
m = hashlib.md5(s.encode())
res = m.hexdigest()
print(res)
# MD5加密+加盐
def md5(s,salt=''):
new_s = str(s) + salt
m = hashlib.md5(new_s.encode())
return m.hexdigest()
# sha256加密
m = hashlib.sha3_256(s.encode())
res = m.hexdigest()
print(res)
# base64加密
m = base64.b64encode(s.encode())
res = m.decode()
print(res)
# base64解密
b = base64.b64decode('MTIz')
res = b.decode()
print(res)