simple_rsa icon indicating copy to clipboard operation
simple_rsa copied to clipboard

Failed to get string encoded: 'Encrypt failure.'.

Open alexlovar opened this issue 6 years ago • 4 comments

hi, i try to implent this plugin, but i have this error in the simple_rsa .dart i'm using the same public and private key from your sample. this is my flutter code:

                onPressed: () async {
                  String tmp = "";
                  print('pressed: '+textEditingController.text);
                  try {
                    final tmp = await encryptString(textEditingController.text, PUBLIC_KEY);
                    setState(() {
                      _stringEncoded = tmp;
                    });

                  } catch (e) {
                    print(e);
                  }
                },

this the Run log on android studio:

I/flutter (22690): pressed: new encrypted W/System.err(22690): java.lang.Exception: java.lang.IllegalArgumentException: bad base-64 W/System.err(22690): at com.juanito21.simplersa.SimpleRsaPlugin.encryptData(SimpleRsaPlugin.kt:86) W/System.err(22690): at com.juanito21.simplersa.SimpleRsaPlugin.onMethodCall(SimpleRsaPlugin.kt:43) W/System.err(22690): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) W/System.err(22690): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) W/System.err(22690): at android.os.MessageQueue.nativePollOnce(Native Method) W/System.err(22690): at android.os.MessageQueue.next(MessageQueue.java:325) W/System.err(22690): at android.os.Looper.loop(Looper.java:142) W/System.err(22690): at android.app.ActivityThread.main(ActivityThread.java:6696) W/System.err(22690): at java.lang.reflect.Method.invoke(Native Method) W/System.err(22690): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) W/System.err(22690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) E/MethodChannel#juanito21.com/simple_rsa(22690): Failed to handle method call E/MethodChannel#juanito21.com/simple_rsa(22690): java.lang.IllegalStateException: Reply already submitted E/MethodChannel#juanito21.com/simple_rsa(22690): at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174) E/MethodChannel#juanito21.com/simple_rsa(22690): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:208) E/MethodChannel#juanito21.com/simple_rsa(22690): at com.juanito21.simplersa.SimpleRsaPlugin.onMethodCall(SimpleRsaPlugin.kt:50) E/MethodChannel#juanito21.com/simple_rsa(22690): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) E/MethodChannel#juanito21.com/simple_rsa(22690): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#juanito21.com/simple_rsa(22690): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#juanito21.com/simple_rsa(22690): at android.os.MessageQueue.next(MessageQueue.java:325) E/MethodChannel#juanito21.com/simple_rsa(22690): at android.os.Looper.loop(Looper.java:142) E/MethodChannel#juanito21.com/simple_rsa(22690): at android.app.ActivityThread.main(ActivityThread.java:6696) E/MethodChannel#juanito21.com/simple_rsa(22690): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#juanito21.com/simple_rsa(22690): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) E/MethodChannel#juanito21.com/simple_rsa(22690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) E/FlutterNativeView(22690): Uncaught exception in binary message listener E/FlutterNativeView(22690): java.lang.IllegalStateException: Reply already submitted E/FlutterNativeView(22690): at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174) E/FlutterNativeView(22690): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:218) E/FlutterNativeView(22690): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/FlutterNativeView(22690): at android.os.MessageQueue.nativePollOnce(Native Method) E/FlutterNativeView(22690): at android.os.MessageQueue.next(MessageQueue.java:325) E/FlutterNativeView(22690): at android.os.Looper.loop(Looper.java:142) E/FlutterNativeView(22690): at android.app.ActivityThread.main(ActivityThread.java:6696) E/FlutterNativeView(22690): at java.lang.reflect.Method.invoke(Native Method) E/FlutterNativeView(22690): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) E/FlutterNativeView(22690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) I/flutter (22690): Failed to get string encoded: 'Encrypt failure.'.

alexlovar avatar Oct 28 '18 17:10 alexlovar

hi, i try and i haven t this problem... have you find the problem?

EDIT: have you try the example? it work?

juani21 avatar Nov 05 '18 13:11 juani21

hi, i changed to another plugin,

alexlovar avatar Nov 09 '18 18:11 alexlovar

hi, i changed to another plugin,

hi, what?

I write this because i not finded a plugin..

Than you

juani21 avatar Nov 09 '18 18:11 juani21

Checkout this https://github.com/giandifra/simple_rsa/issues/5#issuecomment-464449870, might be helpful

riftninja avatar Feb 17 '19 12:02 riftninja