Skip to content

参考资料:成都市中小学教师继续教育网登录密码加密 #17

New issue

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

Open
s0ing opened this issue Apr 17, 2025 · 0 comments
Open

Comments

@s0ing
Copy link

s0ing commented Apr 17, 2025

# -*- coding: utf-8 -*-
"""
file: test.py
create: 2025/4/17 17:13
author: s0ing
summary: 
"""

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import binascii
'''
var pass = 1
const secretPassphrase = '4d8f3d65-d015-450d-8e75-58a50f5a'
var key = CryptoJS.enc.Utf8.parse(secretPassphrase);//32位
var iv = CryptoJS.enc.Utf8.parse("1234567890000000");//16位
var password = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(pass), key, {
                        iv: iv,
                        mode: CryptoJS.mode.CBC,
                        padding: CryptoJS.pad.Pkcs7
                    });
password.ciphertext.toString()
'''


passtr = 1
key = str('4d8f3d65-d015-450d-8e75-58a50f5a').encode('utf-8')
iv = str('1234567890000000').encode('utf-8')
# 创建 AES 加密器对象,使用 CBC 模式
cipher = AES.new(key, AES.MODE_CBC, iv)
# 对数据进行 PKCS7 填充
padded_data = pad(str(passtr).encode('utf-8'), AES.block_size)
# 执行加密操作
ciphertext = cipher.encrypt(padded_data)
print(ciphertext)
# 将密文转换为十六进制字符串
encrypted_hex = binascii.hexlify(ciphertext).decode('utf-8')
print("加密后的密文(十六进制):", encrypted_hex)

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant