% zig build run -- ~/Downloads/gu9m3isal4ga1.jpg
9747fe70814f566b6ccfaf624fac8cb59d66203fbbb48fd8110eac49efdeb98e
Or
% zig build
% ./zig-out/bin/sha256sum ~/Downloads/gu9m3isal4ga1.jpg
9747fe70814f566b6ccfaf624fac8cb59d66203fbbb48fd8110eac49efdeb98e
I have changed to using hashFile from zig-extras after this comment by meghan (nektro):
using https://github.com/nektro/zig-extras/blob/master/src/lib.zig#L168 you can avoid the heap allocation and hash arbitrarily large inputs
by passing in file.reader() and hash.writer()
also the hasher is meant to be made an instance of as seen in https://github.com/nektro/zig-extras/blob/master/src/lib.zig#L155
https://discord.com/channels/605571803288698900/1075367108516515881/1075367621689610270
- sha256 example ziglang/zig#13400
- from hex https://github.com/hexops/mach/blob/35ae2d7ac795395291d0cd95646ac138a48c8762/tools/wasmserve/wasmserve.zig#L1171
- https://github.com/tigerbeetledb/tigerbeetle/blob/0e32c5b5c5a38fb42946d2bc5451a3e87f759be7/src/vopr.zig#L377
- https://github.com/kubkon/zld/blob/4800da973230dae0897892a4d89666b39d096791/src/MachO/CodeSignature.zig#L304
- https://github.com/mathetake/proxy-wasm-zig-sdk/blob/75e2a742912f85bcdd2b7baf33610a45cb1c9105/example/example.zig#L740
- https://ziglearn.org/chapter-2/#crypto
- A tour of std.crypto in Zig 0.7.0 - Frank Denis - YouTube
- https://stackoverflow.com/questions/70189554/how-can-you-create-a-buffer-of-the-same-size-as-a-file/72334950#72334950
- https://stackoverflow.com/questions/68368122/how-to-read-a-file-in-zig/68879352#68879352