python 在 Windows下使用AES时要安装的是pycryptodome 模块 pip install pycryptodome
python 在 Linux下使用AES时要安装的是pycrypto模块 pip install pycrypto
from Crypto.Cipher import AES import base64 import json import requests class Aes_ECB(object): def __init__(self, key): self.key = key self.MODE = AES.MODE_ECB self.BS = AES.block_size self.pad = lambda s: s + (self.BS - len(s) % self.BS) * chr(self.BS - len(s) % self.BS) self.unpad = lambda s: s[0:-ord(s[-1])] # str不是16的倍数那就补足为16的倍数 def add_to_16(value): while len(value) % 16 != 0: value += '