[python] M2Crypto를 사용하여 AES 복호화를 수행하는 방법은 어떻게 되나요?

우선 M2Crypto를 설치해야 합니다. 아래 명령을 사용하여 설치할 수 있습니다:

pip install M2Crypto

다음으로, 다음과 같은 코드를 사용하여 AES 복호화를 수행할 수 있습니다:

from M2Crypto.EVP import Cipher

def aes_decrypt(key, iv, ciphertext):
    cipher = Cipher(alg='aes_256_cbc', key=key, iv=iv, op=0)
    decrypted = cipher.update(ciphertext)
    decrypted += cipher.final()
    return decrypted

key = b'my_secret_key_1234'  # 32 bytes key for AES-256
iv = b'initialization_ve'     # 16 bytes IV for AES
ciphertext = b'\xc0\xee...\x8e'  # encrypted data

decrypted_data = aes_decrypt(key, iv, ciphertext)
print(decrypted_data.decode('utf-8'))

aes_decrypt 함수는 주어진 키, 초기화 벡터 및 암호화된 텍스트로 AES 복호화를 수행합니다. 위의 예제에서는 UTF-8로 디코딩된 복호화된 데이터를 출력합니다.

M2Crypto 공식 문서 및 추가 자료를 참고하여 더 자세한 정보를 얻을 수 있습니다.