decrypt method

  1. @override
Future<List<int>> decrypt(
  1. SecretBox secretBox, {
  2. required SecretKey secretKey,
  3. List<int> aad = const <int>[],
  4. int keyStreamIndex = 0,
  5. Uint8List? possibleBuffer,
})

Decrypts a ciphertext.

Parameter keyStreamIndex allows you to choose offset in the keystream.

For other arguments, see Cipher.decrypt.

Implementation

@override
Future<List<int>> decrypt(
  SecretBox secretBox, {
  required SecretKey secretKey,
  List<int> aad = const <int>[],
  int keyStreamIndex = 0,
  Uint8List? possibleBuffer,
}) {
  if (!kIsWeb &&
      isSupportedPlatform &&
      FlutterCryptography.isPluginPresent &&
      channelPolicy.matches(length: secretBox.cipherText.length)) {
    return FlutterCipher.decryptWithPlugin(
      name: channelCipherName,
      cipher: this,
      fallback: this.fallback,
      secretBox: secretBox,
      secretKey: secretKey,
      aad: aad,
    );
  }

  final fallback = this.fallback;
  if (fallback == null) {
    throw UnsupportedError('No fallback was specified.');
  }

  return fallback.decrypt(
    secretBox,
    secretKey: secretKey,
    aad: aad,
  );
}