encryptText static method

CryptEnvelope encryptText(
  1. String text, {
  2. required Uint8List key,
  3. CryptAlgorithm algorithm = CryptAlgorithm.chacha20Poly1305,
  4. Uint8List? nonce,
  5. List<int>? aad,
})

Cifra text (UTF-8) e retorna um CryptEnvelope sem chave.

  • key : obrigatória; tamanho depende de algorithm.
  • algorithm : padrão CryptAlgorithm.chacha20Poly1305 (AEAD).
  • nonce : nonce/IV/ICB; se omitido, gerado aleatoriamente.
  • aad : dados autenticados não cifrados (apenas modos AEAD).

Implementation

static CryptEnvelope encryptText(
  String text, {
  required Uint8List key,
  CryptAlgorithm algorithm = CryptAlgorithm.chacha20Poly1305,
  Uint8List? nonce,
  List<int>? aad,
}) =>
    encryptBytes(
      utf8.encode(text),
      key: key,
      algorithm: algorithm,
      nonce: nonce,
      aad: aad,
    );