encryptAesCbc static method

EncryptedPayload encryptAesCbc(
  1. List<int> bytes, {
  2. Uint8List? key,
  3. Uint8List? iv,
})

Criptografa bytes com AES-CBC + PKCS#7 e retorna um EncryptedPayload.

⚠️ Não autenticado — use AES-GCM ou ChaCha20-Poly1305 quando precisar de integridade garantida.

  • key : 16 bytes (AES-128) ou 32 bytes (AES-256). Padrão: 32 bytes.
  • iv : 16 bytes. Se omitido, gera um IV aleatório seguro.

Implementation

static EncryptedPayload encryptAesCbc(
  List<int> bytes, {
  Uint8List? key,
  Uint8List? iv,
}) =>
    AesCbc(
      key: key ?? generateKey(),
      iv: iv ?? generateIv(),
    ).encrypt(bytes);