Skip to Content
oxcrypto
Block ciphersLegacy ciphers

CAST5

CAST5 block cipher selector.

from oxcrypto.cipher.cast5 import CAST5
from oxcrypto.cipher.hazmat import decrypt_block, encrypt_block

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

Warning

Legacy: CAST5 has 64-bit blocks. Use it only to read or produce data for existing formats.

Variants: CAST5.CAST5.

Standard: RFC 2144.

Accepts keys of 5 to 16 bytes.

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