-
Notifications
You must be signed in to change notification settings - Fork 6
SHA1 digest
Chung Leong edited this page Aug 8, 2024
·
5 revisions
This example demonstrates how to use the following Zig code to calculate the SHA-1 digest of a file:
const std = @import("std");
pub fn sha1(bytes: []const u8) [std.crypto.hash.Sha1.digest_length * 2]u8 {
var digest: [std.crypto.hash.Sha1.digest_length]u8 = undefined;
std.crypto.hash.Sha1.hash(bytes, &digest, .{});
return std.fmt.bytesToHex(digest, .lower);
}Choose the ecosystem you're interested in: