Skip to main content

aes_cbc_encrypt

Function aes_cbc_encrypt 

Source
pub fn aes_cbc_encrypt<'py>(
    py: Python<'py>,
    key: &[u8],
    iv: &[u8],
    plaintext: &[u8],
    pad: bool,
) -> PyResult<Bound<'py, PyBytes>>
Expand description

Encrypt data using AES-CBC.

Key length determines the AES variant: 16 → AES-128, 24 → AES-192, 32 → AES-256. iv must be 16 bytes.

When pad=True (default) PKCS#7 padding is applied automatically. When pad=False the caller is responsible for correct block alignment.

import synta

ct = synta.aes_cbc_encrypt(key_32, iv_16, plaintext)
ct_no_pad = synta.aes_cbc_encrypt(key_16, iv_16, aligned_data, pad=False)