Made some advancements on the cryptographic primitives implementation

This commit is contained in:
Gu://em_ 2026-07-03 21:56:17 +02:00
parent cb72a9cdc9
commit 0eae5818a0
8 changed files with 69 additions and 17 deletions

View file

@ -1,7 +1,18 @@
pub const Implementation = struct {
hash: *const fn (buffer: []const u8, out: []u8) void,
};
pub const defaultImplementation = struct {
const Sha256 = @import("std").crypto.hash.sha2.Sha256;
const HASH_LEN = 32; // In bytes
pub fn hash(buffer: []const u8, out: []u8) !void {
if (out.len < HASH_LEN) {
return error.BufferTooShort;
}
Sha256.hash(buffer, out, .{});
}
};