机器人
AI 摘要
切换
CatGPT - TianliGPT(1)
本节课主要学习了 Python 中的几种加密工具

Python 中的加密工具

hashlib 模块介绍

  • 难破解
  • 不可逆

hashlib 模块中的常用方法

函数名 参数 介绍 举例 返回值
md5 byte Md5 算法加密 hashlib.md5(b'hello') Hash 对象
sha1 byte Sha1 算法加密 hashlib.sha1(b'hello') Hash 对象
sha256 byte Sha256 算法加密 hashlib.sha256(b'hello') Hash 对象
sha512 byte Sha512 算法加密 hashlib.sha512(b'hello') Hash 对象

代码

base64 模块介绍

  • 通用型
  • 可解密

base64 模块的常用方法

函数名 参数 介绍 举例 返回值
encodestring Byte 进行 base64 加密 base64.encodestring(b'py') Byte
decodingstring Byte 对 base64 解密 base64.decodestring(b'eGlhb211\n') Byte
encodebytes(推荐) Byte 进行 bese64 加密 base64.encodebytes(b'py') Byte
decodingbytes(推荐) Byte 对 base64 解密 base64.decodebytes(b'eGlhb211\n') Byte

代码