-
-
Notifications
You must be signed in to change notification settings - Fork 346
fix SHA256Sum #50
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
fix SHA256Sum #50
Conversation
|
Nice catch, @antoin-m! Thanks for the fix. @thomaspoignant, as the author of this code in #40, did you have a specific reason for doing it this way in |
bitfield
left a comment
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.
Nicely done!
This is a good suggestion, but I think it fails the 'one-liner' test. It should be possible to do most of what you want to do with just a single-line chain of I agree that there are other valid uses for checksums which don't require strong hashing, but I'm sorry to say that in my experience, if an |
It was different in the sink cause you can have something else than a file, you can do something like But @antoin-m is right putting the whole file in memory can be a problem, and I have check the doc and what I said was not clear. @bitfield do you think we should keep the 2 functions? |
|
|
I think it's worth adding that 90% of all programmers are beginners (source: I made this figure up) and so a well-designed library or language will make the simple and obvious thing the safe and reliable thing. If you want to do something potentially unsafe, it's fine to have to do a little more work to enable it. |
|
Great job @antoin-m, thanks again! |
Hi 👋
This is a fix for #49
According to the docs, here is how the hash functions should be used: https://golang.org/pkg/crypto/sha256/#New
Here is the same test (hashing a 1GB file) with the fix applied:
IMHO there should be a
sinks.CheckSum(hash.Hash)method instead. This way you could hash files with any algorithm you like. A checksum doesn't have to be cryptographically secure as mentioned #39 (comment), it's just a way to verify a file's integrity. People often share MD5 hashes because they're less CPU intensive to compute.