Made some advancements on the cryptographic primitives implementation
This commit is contained in:
parent
cb72a9cdc9
commit
0eae5818a0
8 changed files with 69 additions and 17 deletions
|
|
@ -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, .{});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue