Dart Requires Chilkat v11.0.0+
Dart
RSA Import Public Key from Certificate PEM
See more RSA Examples
Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final cert = CkCert();
try {
cert.loadFromFile('qa_data/pem/mf_public_rsa.pem');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final pubKey = CkPublicKey();
cert.getPublicKey(pubKey);
final rsa = CkRsa();
rsa.usePublicKey(pubKey);
rsa.encodingMode = 'base64';
final encryptedStr = rsa.encryptStringENC('hello', false);
print('encrypted string = $encryptedStr');
}