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

how to parse private key directly instead from a .pem file? #244

Open PeterTF656 opened 2 years ago

PeterTF656 commented 2 years ago
final privKey = RSAKeyParser().parse( "private key");
final encrypter = Encrypter(RSA(privateKey: privKey)); **//here it gives me error, because RSAKeyParser().parse() returns RSAAsymmetricKey**
UKnowWhoIm commented 2 years ago

You need to cast it to RSAPrivateKey. To do that you need to add a direct dependency to pointycastle.

import 'package:pointycastle/asymmetric/api.dart';

private = RSAKeyParser().parse(key_string) as RSAPrivateKey

A direct function like RSAKeyParser().parsePrivateKey() would've been a nice addition @leocavalcante

Is anyone working on that?