import base64
import json
import time
ctime = str(time.time())
user_str = json.dumps({'user_name':user_name, 'user_type':user_type, 'user_id':user_id})
# 加密
token = base64.b64encode(user_str.encode(encoding='utf-8')).decode()
# 解密
user_str = base64.b64decode(token.encode(encoding='utf-8')).decode()
Python 爬虫处理base64加密,解密方法
于 2020-07-28 09:47:58 首次发布

本文介绍了一个使用Python实现的Base64编码和解码的简单示例,包括如何将JSON格式的用户信息字符串进行Base64加密,并在需要时将其解密回原始字符串。此过程涉及到对时间戳的生成、JSON数据的处理以及Base64编码库的使用。
1万+

被折叠的 条评论
为什么被折叠?



