encrypt method

  1. @override
Future<SecretBox> encrypt(
  1. List<int> clearText, {
  2. required SecretKey secretKey,
  3. List<int>? nonce,
  4. List<int> aad = const <int>[],
})
override

Encrypts bytes and returns SecretBox. Authenticates SecretBox with macAlgorithm, decrypts it, and returns the cleartext.

You must give a SecretKey that has the correct length and type.

Optional parameter nonce (also known as "initialization vector", "IV", or "salt") is some non-secret unique sequence of bytes. If you don't define it, the cipher will generate nonce for you.

Parameter aad can be used to pass Associated Authenticated Data (AAD). If you pass a non-empty list and the underlying cipher doesn't support AAD, the method will throw ArgumentError.

Implementation

@override
Future<SecretBox> encrypt(
  List<int> clearText, {
  required SecretKey secretKey,
  List<int>? nonce,
  List<int> aad = const <int>[],
}) {
  return fallback.encrypt(
    clearText,
    secretKey: secretKey,
    nonce: nonce,
    aad: aad,
  );
}