encryptChaCha20 function

Future<Uint8List> encryptChaCha20(
  1. Uint8List key,
  2. Uint8List nonce,
  3. Uint8List data
)

Implementation

Future<Uint8List> encryptChaCha20(
    Uint8List key, Uint8List nonce, Uint8List data) async {
  final algorithm = Chacha20(macAlgorithm: MacAlgorithm.empty);
  final skey = SecretKey(key);
  final secretBox = await algorithm.encrypt(
    data,
    secretKey: skey,
    nonce: nonce,
  );

  return Uint8List.fromList(secretBox.cipherText);
}