Sample code for 30+ languages & platforms
React Native

Example: Crypt2.SetDecryptCert2 method

Demonstrates how to call the SetDecryptCert2 method. This example loads the certificate and private key from PEM files:

PEM Format

Certificate file (cert.pem or cert.crt):

-----BEGIN CERTIFICATE-----
MIID... (base64-encoded data)
-----END CERTIFICATE-----

Private key file (key.pem or key.key):

-----BEGIN PRIVATE KEY-----
MIIE... (base64-encoded data)
-----END PRIVATE KEY-----

Chilkat React Native Downloads

React Native
import { Cert, Crypt2, PrivateKey } from '@chilkat/react-native'

function chilkatExample() {
  const cert = new Cert();
  cert.loadFromFile('c:/certs_and_keys/certAbc.pem');
  // Assume success...

  const privKey = new PrivateKey();
  privKey.loadAnyFormatFile('c:/certs_and_keys/certAbc_key.pem', '');
  // Assume success...

  const crypt = new Crypt2();

  crypt.cryptAlgorithm = 'pki';

  // ...
  // ...

  try {
    crypt.setDecryptCert2(cert, privKey);
  } catch {
    console.log(crypt.lastErrorText);
    return;
  }

  console.log('Success.');
}