Zig
Zig
Compute Glacier SHA256 Linear Hash of a File
See more Amazon Glacier Examples
Computes the Amazon Glacier SHA256 linear hash for a file.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 crypt = try chilkat.Crypt2.init();
defer crypt.deinit();
// The "linear hash" is simply the SHA256 hash of the file bytes.
crypt.setHashAlgorithm("sha256");
// Return the hash in lowercase hexidecimal format.
crypt.setEncodingMode("hexlower");
const linear_hash_hex = try crypt.hashFileENC(alloc, "qa_data/jpg/penguins.jpg");
std.debug.print("SHA256 linear hash = {s}\n", .{linear_hash_hex});
}