CFB-8
CFB-8 mode for any block cipher selector.
from oxcrypto.cipher.cfb8 import CFB8
from oxcrypto.cipher.aes import AES
mode = CFB8.CFB8
key = AES.AES128.generate_key()
iv = bytes(16) # use a fresh, unpredictable IV for every message
ciphertext = mode.encrypt(key, b"hello", cipher=AES.AES128, iv=iv)
assert mode.decrypt(key, ciphertext, cipher=AES.AES128, iv=iv) == b"hello"
encryptor = mode.encryptor(key, cipher=AES.AES128, iv=iv)
assert encryptor.update(b"hel") + encryptor.update(b"lo") + encryptor.finalize() == ciphertextStandard: 8-bit CFB from NIST SP 800-38A.
Data of any length is accepted. These modes provide no integrity; prefer an AEAD.
encryptor and decryptor return a single-use CipherContext: call update any number of times, then finalize once. Further calls raise ValueError.