Description: 程序员老王的个人博客
blog (28744) php (15888) linux (6769) mysql (4313) python (3834) typecho (1755) js (1674) golang (632) 程序员 (415)
程序员老王的个人博客
from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad def encrypt_text(text: str, key_hex: str, iv_hex: str) -> str: key = bytes.fromhex(key_hex) iv = bytes.fromhex(iv_hex) text = text.encode('utf-8') cipher = AES.new(key, AES.MODE_CBC, iv) encrypted_data = cipher.encrypt(pad(text, AES.block_size)) return encrypted_data.hex() def decrypt_text(text: str, key_hex: str, iv_hex: str) -> str: key = bytes.fromhex(key_hex) iv = bytes.fromhex(iv_hex) text = bytes.fromhex(text) cipher = AES.new(ke
backend下目录结构