Sample code for 30+ languages & platforms
Zig

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

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();

    const cert = try chilkat.Cert.init();
    defer cert.deinit();

    cert.loadPfxFile("c:/pfx_files/my.pfx", "password") catch {
        std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
        return;
    };

    const decrypt = try chilkat.Crypt2.init();
    defer decrypt.deinit();
    decrypt.setCryptAlgorithm("pki");

    decrypt.setDecryptCert(cert) catch {
        std.debug.print("{s}\n", .{try decrypt.getLastErrorText(alloc)});
        return;
    };

    const bd = try chilkat.BinData.init();
    defer bd.deinit();
    try bd.loadFile("c:/someDir/pkcs7_encrypted.dat");

    decrypt.decryptBd(bd) catch {
        std.debug.print("{s}\n", .{try decrypt.getLastErrorText(alloc)});
        return;
    };

    // bd contains the decrypted content.
}