open method

  1. @override
Future<Uint8List> open(
  1. Uint8List sealed
)
override

The bytes seal was given. Throws when sealed is not something this cipher sealed — a different key, a truncated file, a tampered one.

Implementation

@override
Future<Uint8List> open(Uint8List sealed) async {
  if (sealed.length < _nonceBytes + _tagBits ~/ 8) {
    throw const FormatException('Too short to be a sealed cache file');
  }
  final nonce = Uint8List.sublistView(sealed, 0, _nonceBytes);
  final body = Uint8List.sublistView(sealed, _nonceBytes);
  try {
    return _cipher(nonce, encrypt: false).process(body);
  } on InvalidCipherTextException {
    throw const FormatException('Not sealed under this key');
  }
}