import base64
#此加密方式是为了一些参数在抓包时不被读取,加密后在存入数据库前还可以再解密,然后保存解密后的内容,md5不能解密
s='123456'
new_s=base64.b64encode(s.encode())#加密
# print(new_s)
old_s=base64.b64decode(new_s.decode())#解密
# print(old_s)
def bs_64_encode(st):
salt='123456'
new_s=salt+st
encode_st=base64.b64encode(new_s.encode()).decode()
return encode_st
print(bs_64_encode('nini'))
def bs_64_decode(st):
salt='123456'
decode_st=base64.b64decode(st).decode()
res=decode_st.replace(salt,'')
return res
print(bs_64_decode('MTIzNDU2bmluaQ=='))
转载于:https://www.cnblogs.com/liushuxian/p/11344770.html