seal method

  1. @override
Future<Uint8List> seal(
  1. Uint8List plain
)
override

plain, sealed so that open returns it and nothing else does.

Implementation

@override
Future<Uint8List> seal(Uint8List plain) async {
  final nonce = Uint8List.fromList([
    for (var i = 0; i < _nonceBytes; i++) _random.nextInt(256),
  ]);
  final sealed = _cipher(nonce, encrypt: true).process(plain);
  return Uint8List(nonce.length + sealed.length)
    ..setAll(0, nonce)
    ..setAll(nonce.length, sealed);
}