python标准库-base64模块的加密解密

关于python中base64加密解密方法的代码

以"*encode"结尾的方法用于将二进制串转为base64编码格式的字符串,以“*decode”结尾的方法用于将base64格式的字符串重新转为二进制串

Base64是一种基于64个可打印字符来表示二进制数据的表示方法。

Base64 编码和解码:

b64encode 的参数 s 的类型必须是字节包(bytes)。

b64decode 的参数 s 可以是字节包(bytes),也可以是字符串(str)。

代码示例:

root@localhost:~# python
Python 2.7.16 (default, Oct 10 2019, 13:47:52) 

>>> import base64
>>> str = 'Hello'
>>> base64.b64encode(str)
'SGVsbG8='
>>> base64.b64decode('SGVsbG8=')
'Hello'
原文地址:https://www.cnblogs.com/mcladyr/p/12626438.html