密钥和 IV 均为 "jU7hu4tgw99Hj80t"。
加密算法:AES-128-CBC + ZeroPadding
用python写一个加密例子,易语言自己写!
[Python] 纯文本查看 复制代码 from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import base64
KEY = b"jU7hu4tgw99Hj80t"
IV = b"jU7hu4tgw99Hj80t"
def encrypt(plain_text):
plain_bytes = plain_text.encode('utf-8')
padded_bytes = plain_bytes + b'\0' * (16 - len(plain_bytes) % 16)
cipher = AES.new(KEY, AES.MODE_CBC, IV)
cipher_bytes = cipher.encrypt(padded_bytes)
return base64.b64encode(cipher_bytes).decode('utf-8')
def decrypt(cipher_text):
cipher_bytes = base64.b64decode(cipher_text)
cipher = AES.new(KEY, AES.MODE_CBC, IV)
decrypted_bytes = cipher.decrypt(cipher_bytes)
decrypted_bytes = decrypted_bytes.rstrip(b'\0')
return decrypted_bytes.decode('utf-8')
if __name__ == '__main__':
plaintext = "2222222222"
encrypted = encrypt(plaintext)
print(f"加密结果: {encrypted}")
decrypted = decrypt(encrypted)
print(f"解密结果: {decrypted}")
补充内容 (2025-6-17 09:09):
看错了。。还以为登录。.. |