Sample code for 30+ languages & platforms
React Native

Duplicate openssl smime -decrypt -in some_file.dat.enc -binary -inform DER -inkey private.key -out some_file.dat

See more OpenSSL Examples

Demonstrates how to decrypt binary DER that was encrypted using the following openssl command:
openssl smime -encrypt -binary -aes-256-cbc -in some_file.dat -out some_file.dat.enc -outform DER cert.crt

Chilkat React Native Downloads

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

async function chilkatExample() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  // Duplicates the following openssl command:
  // openssl smime -decrypt -in hello.txt.enc -binary -inform DER -inkey private.key -out hello.txt

  const cert = new Cert();
  try {
    cert.loadFromFile('qa_data/openssl/EE.cer');
  } catch {
    console.log(cert.lastErrorText);
    return;
  }

  const bd = new BinData();
  bd.loadFile('qa_data/openssl/EE.key');
  // Assuming success..

  const privKey = new PrivateKey();
  try {
    privKey.loadAnyFormat(bd, '');
  } catch {
    console.log(privKey.lastErrorText);
    return;
  }

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

  crypt.cryptAlgorithm = 'PKI';
  try {
    await crypt.ckDecryptFileAsync('qa_data/openssl/hello.txt.enc', 'qa_output/hello.txt');
  } catch {
    console.log(crypt.lastErrorText);
    return;
  }

  console.log('Success.');
}