依赖包安装部分
- 安装依赖包: pip install pycryptodome
- 在你的python环境中的下图红框路径中找到 crypto 将其改成 Crypto
代码部分
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2018-11-27 17:21:23 # @Author : Sheldon (thisisscret@qq.com) # @blogs : 谢耳朵的派森笔记 # @Link : https://www.cnblogs.com/shld/
from Crypto.Cipher import AES from binascii import b2a_base64, a2b_base64 def rpad(text, divisor: int, suffix): remain = len(text) % divisor if remain > 0: text += suffix * (divisor - remain) return text def encrypt(text, salt, key): fmtkey, fmtiv = map(lambda s: s.encode()[:16].ljust(16, b'