Dart Requires Chilkat v11.0.0+
Dart
Use Base64 RSA Key to Encrypt
See more RSA Examples
Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final pubkey = CkPublicKey();
try {
pubkey.loadBase64('MIICdgIBADA ... A9PXLk+j5A==');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final rsa = CkRsa();
try {
rsa.usePublicKey(pubkey);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
rsa.encodingMode = 'base64';
final encryptedStr = rsa.encryptStringENC('12345678', false);
print(encryptedStr);
}