Draft
Conversation
15c1af8 to
1f448d9
Compare
jakobnissen
reviewed
Apr 11, 2026
| for (name, namestr, numbytes) in [(:SHA1, "SHA1", 20), (:SHA256, "SHA256", 32)] | ||
| @eval Base begin | ||
| struct $name | ||
| bytes::NTuple{20, UInt8} |
Member
There was a problem hiding this comment.
Suggested change
| bytes::NTuple{20, UInt8} | |
| bytes::NTuple{$(numbytes), UInt8} |
| end | ||
| function $name(bytes::Vector{UInt8}) | ||
| length(bytes) == $numbytes || | ||
| throw(ArgumentError("wrong number of bytes for " * string($namestr) * ": $(length(bytes))")) |
Member
There was a problem hiding this comment.
Suggested change
| throw(ArgumentError("wrong number of bytes for " * string($namestr) * ": $(length(bytes))")) | |
| throw(ArgumentError("wrong number of bytes for " * string($namestr) * ": Expected $(numbytes) bytes, got $(length(bytes))")) |
| show(io::IO, hash::SHA1) = print(io, "SHA1(\"", hash, "\")") | ||
| string(hash::$name) = bytes2hex(hash.bytes) | ||
| print(io::IO, hash::$name) = bytes2hex(io, hash.bytes) | ||
| show(io::IO, hash::$name) = print(io, string($namestr) * "(\"", hash, "\")") |
Member
There was a problem hiding this comment.
Suggested change
| show(io::IO, hash::$name) = print(io, string($namestr) * "(\"", hash, "\")") | |
| show(io::IO, hash::$name) = print(io, namestr * "(\"", hash, "\")") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We're going to start recording
git-tree-sha256in the General registry, which means that we should eventually also start trackinggit-tree-sha256in manifests. And so eventually we'll want to use it in code loading, which will require it to be in Base.I'd like to use this in the following places: