base64的编码和解码

发布时间 2024-01-03 20:10:44作者: wellplayed

base64介绍

base64是编码解码方式,而不是加密方式

 

使用方法

首先需要导入base64模块

import base64

 

base64编码:

只能转换bytes格式数据

base64.b64encode(转换数据.encode('utf-8'))

 

base64解码:

base64编码可能需要在末尾加=补齐

base64.b64decode('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9')