toBytes method

Uint8List toBytes()

Serializes to bytes: nonce (12 bytes) + ciphertext.

This format is suitable for storage or transmission.

Implementation

Uint8List toBytes() {
  final result = Uint8List(nonce.length + ciphertext.length);
  result.setAll(0, nonce);
  result.setAll(nonce.length, ciphertext);
  return result;
}