leocavalcante / encrypt

🔒 A set of high-level APIs over PointyCastle for two-way cryptography.
BSD 3-Clause "New" or "Revised" License
348 stars 141 forks source link

The argument type 'RSAAsymmetricKey' can't be assigned to the parameter type 'RSAPublicKey?'. #227

Open undefinedKey opened 3 years ago

undefinedKey commented 3 years ago

Errors in SDK 2.2.2, Same error as sample code

 var publicKey = RSAKeyParser().parse(pubKey);
  // final publicKey = await parseKeyFromFile<RSAPublicKey>('/public.pem');      //error

/*
*error :
*The argument type 'RSAAsymmetricKey' can't be assigned to the parameter type 'RSAPublicKey?'.
*/
final encrypter = Encrypter(RSA(publicKey : publicKey));
MaoqingW commented 3 years ago

I had the same problem a few days ago and I finally find a solution.hope that is work for you. dynamic publicKey = RSAKeyParser().parse(publicKeyString); As you can see, just change the var to dynamic, then the error is gone.

ericomine commented 3 years ago

I'm also having the same issue. Thanks @MaoqingW, your solution seems to be working for me. But would it not make more sense if the package exported RSAPublicKey and RSAPrivateKey so that the key can be casted?

albert0m commented 2 years ago

yeah, this buffles me

Ahmadre commented 1 year ago

I had the same problem a few days ago and I finally find a solution.hope that is work for you. dynamic publicKey = RSAKeyParser().parse(publicKeyString); As you can see, just change the var to dynamic, then the error is gone.

This is not even working! Why is the package not exporting the models?