Skip to Content
oxcrypto
Block ciphersLegacy ciphers

DES and Triple DES

DES and Triple DES block cipher selector.

from oxcrypto.cipher.des import DES
from oxcrypto.cipher.hazmat import decrypt_block, encrypt_block

cipher = DES.TDES_EEE3
key = cipher.generate_key()
block = bytes(cipher.block_size)
assert decrypt_block(key, encrypt_block(key, block, cipher=cipher), cipher=cipher) == block

Warning

Legacy: DES and Triple DES has 56-bit DES keys and 64-bit blocks. Use it only to read or produce data for existing formats.

Variants: DES.DES, DES.TDES_EDE2, DES.TDES_EDE3, DES.TDES_EEE2, DES.TDES_EEE3.

Standard: FIPS 46-3 (withdrawn) and NIST SP 800-67 (Triple DES withdrawn for encryption after 2023).

Pass the selector as cipher= to any mode. Raw single-block functions live in oxcrypto.cipher.hazmat.