This commit implements every algorithm I have played with so far. It also allows for you to switch which algorithm you want to use at runtime.
10 lines
317 B
Zig
10 lines
317 B
Zig
const std = @import("std");
|
|
const Allocator = std.mem.Allocator;
|
|
|
|
pub fn hash(allocator: Allocator, data: []const u8) ![]u8 {
|
|
const output_hash = try allocator.alloc(u8, std.crypto.hash.sha2.Sha256.digest_length);
|
|
std.crypto.hash.sha2.Sha256.hash(data, @ptrCast(output_hash), .{});
|
|
|
|
return output_hash;
|
|
}
|