某Bit数据解密算法

某Bit数据解密算法


核心部分

from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
import base64


def Ie(e, n, iv):
    """
    e: 被加密的数据 data
    n: AES 解密用到的key(加密的秘钥) necromancer
    iv: 初始化向量(AES CBC模式加密增加随机性加密的一个参数)
    """
    # Convert base64 encoded string to bytes
    e = base64.b64decode(e)

    # Parse key and IV
    key = n.encode('utf-8')
    iv = iv.encode('utf-8')  # Assuming this is the default IV if not provided

    # Create AES cipher in CBC mode
    cipher = AES.new(key, AES.MODE_CBC, iv=iv)

    # Decrypt the data
    decrypted = cipher.decrypt(e)

    # Unpad the decrypted data
    unpadded = unpad(decrypted, AES.block_size)

    # Convert to string
    return unpadded.decode('utf-8')



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.