Sample code for 30+ languages & platforms
Dart

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 Dart Downloads

Dart
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.

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

  final cert = CkCert();
  try {
    cert.loadFromFile('qa_data/openssl/EE.cer');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final bd = CkBinData();
  bd.loadFile('qa_data/openssl/EE.key');
  // Assuming success..

  final privKey = CkPrivateKey();
  try {
    privKey.loadAnyFormat(bd, '');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final crypt = CkCrypt2();
  try {
    crypt.setDecryptCert2(cert, privKey);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  crypt.cryptAlgorithm = 'PKI';
  try {
    crypt.ckDecryptFile('qa_data/openssl/hello.txt.enc', 'qa_output/hello.txt');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print('Success.');
}