Dart
Dart
Example: Crypt2.ClearEncryptCerts method
Demonstrates how to call the ClearEncryptCerts method.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final crypt = CkCrypt2();
// Tell the crypt object to use 3 certificates.
// Do this by calling AddEncryptCert for each certificate.
final cert1 = CkCert();
// ...
// Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
// ...
crypt.addEncryptCert(cert1);
final cert2 = CkCert();
// ...
crypt.addEncryptCert(cert2);
final cert3 = CkCert();
// ...
crypt.addEncryptCert(cert3);
// Params for public-key encryption to create PKCS7 enveloped-data
crypt.cryptAlgorithm = 'pki';
crypt.pkcs7CryptAlg = 'aes';
crypt.keyLength = 256;
crypt.oaepHash = 'sha256';
crypt.oaepPadding = true;
final bd = CkBinData();
// ...
crypt.encryptBd(bd);
// Let's say we now want to encrypt something else with different certs..
// First clear the encryption certs.
crypt.clearEncryptCerts();
final cert4 = CkCert();
// ...
crypt.addEncryptCert(cert4);
final cert5 = CkCert();
// ...
crypt.addEncryptCert(cert5);
// ...
// ...
// Encrypt using cert4 and cert5.
crypt.encryptBd(bd);
}