decrypt method

  1. @override
Future<Uint8List> decrypt(
  1. Uint8List encrypted, {
  2. BiometricPromptInfo? promptInfo,
})
override

Decrypt data using the private key (requires biometric authentication).

Implementation

@override
Future<Uint8List> decrypt(
  Uint8List encrypted, {
  BiometricPromptInfo? promptInfo,
}) async {
  try {
    final Map<String, dynamic> args = {
      'encrypted': encrypted,
    };

    if (promptInfo != null) {
      if (promptInfo.title != null) {
        args['title'] = promptInfo.title;
      }
      if (promptInfo.subtitle != null) {
        args['subtitle'] = promptInfo.subtitle;
      }
      if (promptInfo.description != null) {
        args['description'] = promptInfo.description;
      }
      if (promptInfo.negativeButtonText != null) {
        args['negativeButtonText'] = promptInfo.negativeButtonText;
      }
    }

    final result = await _methodChannel.invokeMethod<Uint8List>(
      'decrypt',
      args,
    );
    if (result == null) {
      throw BiometricCryptoException('Decryption returned null');
    }
    return result;
  } on PlatformException catch (e) {
    throw _convertPlatformException(e);
  }
}