Sample code for 30+ languages & platforms
Zig

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

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    // 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 = try chilkat.Cert.init();
    defer cert.deinit();
    cert.loadFromFile("qa_data/openssl/EE.cer") catch {
        std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
        return;
    };

    const bd = try chilkat.BinData.init();
    defer bd.deinit();
    try bd.loadFile("qa_data/openssl/EE.key");
    // Assuming success..

    const priv_key = try chilkat.PrivateKey.init();
    defer priv_key.deinit();
    priv_key.loadAnyFormat(bd, "") catch {
        std.debug.print("{s}\n", .{try priv_key.getLastErrorText(alloc)});
        return;
    };

    const crypt = try chilkat.Crypt2.init();
    defer crypt.deinit();
    crypt.setDecryptCert2(cert, priv_key) catch {
        std.debug.print("{s}\n", .{try crypt.getLastErrorText(alloc)});
        return;
    };

    crypt.setCryptAlgorithm("PKI");
    crypt.ckDecryptFile("qa_data/openssl/hello.txt.enc", "qa_output/hello.txt") catch {
        std.debug.print("{s}\n", .{try crypt.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("Success.\n", .{});
}