-
Notifications
You must be signed in to change notification settings - Fork 10
Feat/Hashers: Implement sha256d :fixes #3 #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
501399a
4e8e40e
69a2b63
16c7c9c
e59d4f2
87acf2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||||||||||
| const std = @import("std"); | ||||||||||||||
| const Hash = std.crypto.sha256; | ||||||||||||||
|
|
||||||||||||||
| pub const HashEngine = struct { | ||||||||||||||
|
||||||||||||||
| pub const HashEngine = struct { | |
| pub const HashEngine = struct { | |
| const Self = @This(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will also suggest we rename this from HashEngine to Sha256d
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pub fn new() HashEngine { | |
| pub fn init() Self { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return HashEngine{ | |
| .sha256_engine = Hash.Context.init(), | |
| }; | |
| return .{ | |
| .sha256_engine = Hash.Context.init(), | |
| }; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pub fn input(self: *HashEngine, data: []const u8) void { | |
| pub fn input(self: *Self, data: []const u8) void { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pub fn n_bytes_hashed(self: *const HashEngine) usize { | |
| pub fn n_bytes_hashed(self: *const Self) usize { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pub fn final(self: *HashEngine) []u8 { | |
| pub fn final(self: *Self) []u8 { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here why can't you return a [32]u8 as you know the size of the output at compile time no?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u can use here std.testing.expectEqualSlices
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expectEqualSlices is too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it okay? std.crypto.sha256 is located in std.crypto.hash.sha2.Sha256