Zig Requires Chilkat v11.0.0+
Zig
Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem
See more OpenSSL Examples
How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:openssl pkey -in private.pem -pubout -out pubkey.pem
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const pkey = try chilkat.PrivateKey.init();
defer pkey.deinit();
// Load the private key from an PEM file:
pkey.loadPemFile("private.pem") catch {
std.debug.print("{s}\n", .{try pkey.getLastErrorText(alloc)});
return;
};
const pub_key = try chilkat.PublicKey.init();
defer pub_key.deinit();
pkey.toPublicKey(pub_key) catch {};
pub_key.savePemFile(false, "pubKey.pem") catch {
std.debug.print("{s}\n", .{try pub_key.getLastErrorText(alloc)});
return;
};
std.debug.print("Success.\n", .{});
}