Skip to content

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

Open
@s0ing

Description

@s0ing
# -*- 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions