Skip to Content
oxcrypto
Block ciphersLegacy ciphers

RC2

RC2 block cipher selector.

from oxcrypto.cipher.rc2 import RC2
from oxcrypto.cipher.hazmat import decrypt_block, encrypt_block

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

Warning

Legacy: RC2 has a weak key schedule and 64-bit blocks. Use it only to read or produce data for existing formats.

Variants: RC2.RC2.

Standard: RFC 2268. The effective key length equals the key length in bits.

Accepts keys of 1 to 128 bytes; key_size and generate_key() use 32 bytes.

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