rsa_encrypt icon indicating copy to clipboard operation
rsa_encrypt copied to clipboard

parsePublicKeyFromPem: type 'ASN1Object' is not a subtype of type 'ASN1Sequence' in type cast

Open asa08 opened this issue 3 years ago • 0 comments

I want to encrypt using the public key of the String I have.

I got an error with parsePublicKeyFromPem.

  • Code
var helper = RsaKeyHelper();
// a base64 encoded pem string with correct headers and footers
final publicKeyString = '...';
final publicKey = helper.parsePublicKeyFromPem(publicKeyString);
  • Error
The following _CastError was thrown while handling a gesture:
type 'ASN1Object' is not a subtype of type 'ASN1Sequence' in type cast

When the exception was thrown, this was the stack: 
#0      RsaKeyHelper.parsePublicKeyFromPem (package:rsa_encrypt/rsa_encrypt.dart:60:47)
#1      HomeScreenContent.build._openNotification (package:app/garage/pages/home/MY_SCREEN.dart:43:32)
#2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
#3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
#4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
  • flutter --version
Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9b2d32b605 (8 months ago) • 2021-01-22 14:36:39 -0800
Engine • revision 2f0af37152
Tools • Dart 2.10.5

Do you know the solution? Thank you.

asa08 avatar Sep 22 '21 17:09 asa08