We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import binascii import base64
def encrypt_data(userid): # 密钥和初始化向量设置 secret_passphrase = '01aaa85c-c60d-43f6-bf6a-cdaa344d' key = secret_passphrase.encode('utf-8') iv = "1234567890000000".encode('utf-8')
# 确保密钥长度为32位(AES-256) if len(key) < 32: key = key.ljust(32, b'\0') elif len(key) > 32: key = key[:32] # 确保IV长度为16位(AES块大小) if len(iv) != 16: iv = iv[:16] if len(iv) > 16 else iv.ljust(16, b'\0') # 加密用户ID cipher = AES.new(key, AES.MODE_CBC, iv) encrypted_userid = cipher.encrypt(pad(userid.encode('utf-8'), AES.block_size)) # 返回加密后的十六进制字符串 return binascii.hexlify(encrypted_userid).decode('utf-8')
if name == "main":
userid = "11111111111" encrypted_userid = encrypt_data(userid) print(f"Encrypted User ID: {encrypted_userid}")
The text was updated successfully, but these errors were encountered:
No branches or pull requests
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import binascii
import base64
def encrypt_data(userid):
# 密钥和初始化向量设置
secret_passphrase = '01aaa85c-c60d-43f6-bf6a-cdaa344d'
key = secret_passphrase.encode('utf-8')
iv = "1234567890000000".encode('utf-8')
使用示例
if name == "main":
The text was updated successfully, but these errors were encountered: