https://github.com/rofrol/sha256sum-zig
https://github.com/rofrol/sha256sum-zig
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rofrol/sha256sum-zig
- Owner: rofrol
- License: apache-2.0
- Created: 2023-02-08T10:08:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-20T15:06:58.000Z (over 3 years ago)
- Last Synced: 2025-02-19T07:37:06.601Z (over 1 year ago)
- Language: Zig
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Usage
```shell
% zig build run -- ~/Downloads/gu9m3isal4ga1.jpg
9747fe70814f566b6ccfaf624fac8cb59d66203fbbb48fd8110eac49efdeb98e
```
Or
```shell
% zig build
% ./zig-out/bin/sha256sum ~/Downloads/gu9m3isal4ga1.jpg
9747fe70814f566b6ccfaf624fac8cb59d66203fbbb48fd8110eac49efdeb98e
```
## Use hashFile from zig-extras
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
## Links
- sha256 example https://github.com/ziglang/zig/issues/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://www.youtube.com/watch?v=9t6Y7KoCvyk)
- 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