encrypt icon indicating copy to clipboard operation
encrypt copied to clipboard

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

Open PeterTF656 opened this issue 3 years ago • 1 comments

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

PeterTF656 avatar Nov 03 '21 11:11 PeterTF656

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?

UKnowWhoIm avatar Jul 24 '22 17:07 UKnowWhoIm