base64加密解密

 

import base64

msg = '123456'
msg = msg.encode('utf-8')
# 加密
passwd = base64.b64encode(msg)
print(passwd)
# b'MTIzNDU2'

# 解密
res = base64.b64decode(passwd)
result = res.decode('utf-8')
print("res:",result)
# 123456

 

posted @ 2021-03-24 22:09  半日闲1  阅读(204)  评论(0编辑  收藏  举报