encryptString method

  1. @override
Future<String?> encryptString(
  1. String txt,
  2. String publicKey
)
override

Implementation

@override
Future<String?> encryptString(String txt, String publicKey) async {
  try {
    publicKey = publicKey
        .replaceAll("-----BEGIN PUBLIC KEY-----", "")
        .replaceAll("-----END PUBLIC KEY-----", "");
    final result = await methodChannel.invokeMethod<String>(
        'encrypt', {"txt": txt, "publicKey": publicKey});
    return result;
  } on PlatformException catch (e) {
    throw "Failed to get string encoded: '${e.message}'.";
  }
}