Zig Requires Chilkat v11.0.0+
Zig
Base64url Encoding
See more Encryption Examples
Base64url encoding is identical to base64 encoding except it uses non-reserved URL characters (e.g. '–' is used instead of '+', and '_' is used instead of '/') and it omits the padding characters.Chilkat Zig Downloads
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.
const pkey = try chilkat.PrivateKey.init();
defer pkey.deinit();
const rsa = try chilkat.Rsa.init();
defer rsa.deinit();
rsa.genKey(1024, pkey) catch {};
rsa.usePrivateKey(pkey) catch {};
const str_data = "This is the string to be signed.";
// Get the signature in base64url
rsa.setEncodingMode("base64url");
const str_sig = try rsa.signStringENC(alloc, str_data, "sha256");
std.debug.print("{s}\n", .{str_sig});
}