from Crypto.Cipher import DES3
from Crypto.Cipher import DES3 # Create a new DES3 object with a 128-bit key key = b'Sixteen byte key' cipher = DES3.new(key, DES3.MODE_EAX) # Encrypt some data plaintext = b'Hello, world!' ciphertext, tag = cipher.encrypt_and_digest(plaintext) # Print the encrypted data and tag print(ciphertext) print(tag)
from Crypto.Cipher import DES3 # Create a new DES3 object with a 192-bit key key = b'Twenty-four byte key!' cipher = DES3.new(key, DES3.MODE_EAX) # Decrypt some data ciphertext = b'\x1b\xf3\x0e\xb2\xe9y\xcc/HF\x0c7\xf1Io' tag = b'v\x8d\xbb\xa5.Z[\xb5\x89<\xe6U+\xae6' plaintext = cipher.decrypt_and_verify(ciphertext, tag) # Print the decrypted data print(plaintext)The Python Crypto.Cipher DES3 new library is part of the PyCryptodome package.