Skip to Content
oxcrypto
Block ciphersLegacy ciphers

Blowfish

Blowfish block cipher selector.

from oxcrypto.cipher.blowfish import BLOWFISH
from oxcrypto.cipher.hazmat import decrypt_block, encrypt_block

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

Warning

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

Variants: BLOWFISH.BLOWFISH.

Standard: Schneier (1993).

Accepts keys of 4 to 56 bytes; key_size is 56.

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