【基础算法】-python字符串加密五种方法
# 1. url编码
from urllib.parse import quote, unquote
name = "王大锤"
# 编码
utf8_name = quote(name) # utf-8
print(utf8_name)
# %E7%8E%8B%E5%A4%A7%E9%94%A4 长度是 9
gbk_name = quote(name, encoding="gbk")
print(gbk_name)
# %CD%F5%B4%F3%B4%B8 长度是 6
# 解码
print(unquote(utf8_name))
print(unquote(gbk_name, encoding="gbk"))
# 王大锤
# 2. Base64编码
# base64编码是将二进制字节流编码为可打印的64个字符
# 以6位分割 bit位都是0,base64约定以‘=’代替
# z -> b'eg=='
import base64
, 相关下载链接:
https://download.csdn.net/download/u014481728/88498803?utm_source=bbsseo