Sample code for 30+ languages & platforms
Zig

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 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();
    try cert.loadFromFile("c:/certs_and_keys/certAbc.pem");
    // Assume success...

    const priv_key = try chilkat.PrivateKey.init();
    defer priv_key.deinit();
    try priv_key.loadAnyFormatFile("c:/certs_and_keys/certAbc_key.pem", "");
    // Assume success...

    const crypt = try chilkat.Crypt2.init();
    defer crypt.deinit();

    crypt.setCryptAlgorithm("pki");

    // ...
    // ...

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

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