React Native
React Native
Example: Crypt2.ClearEncryptCerts method
Demonstrates how to call the ClearEncryptCerts method.Chilkat React Native Downloads
import { BinData, Cert, Crypt2 } from '@chilkat/react-native'
function chilkatExample() {
const crypt = new Crypt2();
// Tell the crypt object to use 3 certificates.
// Do this by calling AddEncryptCert for each certificate.
const cert1 = new Cert();
// ...
// 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);
const cert2 = new Cert();
// ...
crypt.addEncryptCert(cert2);
const cert3 = new Cert();
// ...
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;
const bd = new BinData();
// ...
crypt.encryptBd(bd);
// Let's say we now want to encrypt something else with different certs..
// First clear the encryption certs.
crypt.clearEncryptCerts();
const cert4 = new Cert();
// ...
crypt.addEncryptCert(cert4);
const cert5 = new Cert();
// ...
crypt.addEncryptCert(cert5);
// ...
// ...
// Encrypt using cert4 and cert5.
crypt.encryptBd(bd);
}