18 lines
432 B
Zig
18 lines
432 B
Zig
pub const Implementation = struct {
|
|
|
|
hash: *const fn (buffer: []const u8, out: []u8) void,
|
|
};
|
|
|
|
pub const defaultImplementation = struct {
|
|
|
|
const Sha512 = @import("std").crypto.sha2.Sha512;
|
|
|
|
const HASH_LEN = 64; // In bytes
|
|
|
|
pub fn hash(buffer: []const u8, out: []u8) !void {
|
|
if (out.len < HASH_LEN) {
|
|
return error.BufferTooShort;
|
|
}
|
|
Sha512.hash(buffer, out, .{});
|
|
}
|
|
};
|