Zig
Zig
Example: Crypt2.EncryptSb method
Demonstrates how to call the EncryptSb method.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 crypt = try chilkat.Crypt2.init();
defer crypt.deinit();
const bd_encrypted = try chilkat.BinData.init();
defer bd_encrypted.deinit();
const sb_plain_text = try chilkat.StringBuilder.init();
defer sb_plain_text.deinit();
sb_plain_text.append("Text to be encrypted") catch {};
// ...
// Set the secret key ...
// Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
// Set the IV if needed ...
// ...
crypt.setCharset("utf-8");
crypt.encryptSb(sb_plain_text, bd_encrypted) catch {
std.debug.print("{s}\n", .{try crypt.getLastErrorText(alloc)});
return;
};
}