monolith hash
Compute the SHA-256 fingerprint of a file plus a perceptual hash when the file kind is recognized.
monolith hash <path|-> [--json]| Argument | Description |
|---|---|
<path> | File path. Use - to read bytes from stdin. |
--json | Emit a single JSON object instead of key=value lines. |
What it computes
| Kind | Detected via | Extra hash | Algorithm |
|---|---|---|---|
| Image | magic bytes | phash | 64-bit pHash via @stabilityprotocol.com/phash — same as the API |
| Audio | magic bytes | chromaprint | AcoustID-compatible Chromaprint via rusty-chromaprint-wasm |
| Other | — | — | fingerprint only |
The fingerprint is the SHA-256 of the raw bytes, lowercase hex, prefixed
with 0x. It matches the value the API stores on an Artifact and accepts in
POST /api/v1/artifacts.
Human output (default)
$ monolith hash ./image.png
fingerprint=0x20a7b5ffe611944e5773e165d2d2a25d79cea4880a27dbac4624b3158a7aef7e
kind=image
mime=image/png
phash=918b8b916e4aee91$ monolith hash ./song.mp3
fingerprint=0x6ea817bd7891b4f75dbe37498a36f02b232337f0e8ec04ee4fd5843bed1b2d39
kind=audio
mime=audio/mpeg
chromaprint=AQAAE0mUaEkSZSoAAAAAAAAA...
sampleRate=44100
channels=2
durationSec=183.524JSON output
$ monolith hash ./image.png --json
{"fingerprint":"0x20a7b5ff…","kind":"image","mime":"image/png","ext":"png","phash":"918b8b916e4aee91"}JSON is line-delimited (one object, trailing newline) so it pipes cleanly
into jq:
monolith hash ./image.png --json | jq -r '.fingerprint'Stdin
Pass - as the path to read bytes from stdin. Useful when the file lives
in a remote bucket or is generated on the fly:
$ curl -sS https://example.com/track.mp3 | monolith hash - --json
{"fingerprint":"0x…","kind":"audio","chromaprint":"…","sampleRate":44100,"channels":2,"durationSec":183.524}Pipe into an Artifact
Hash locally, then pass the fingerprint straight into an Artifact:
bash
FP=$(monolith hash ./my-art.png --json | jq -r '.fingerprint')
curl -X POST https://api.joinmonolith.com/api/v1/artifacts \
-H "Authorization: Bearer $MONOLITH_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"markId\": \"$MARK_ID\",
\"fingerprint\": \"$FP\",
\"filename\": \"my-art.png\",
\"mediaType\": \"image/png\",
\"size\": $(wc -c < ./my-art.png)
}"The CLI never sends bytes off your machine. Only the resulting fingerprint and perceptual hash are needed by the API.
Errors
| Exit | Cause | Stderr |
|---|---|---|
1 | File not found | Error: File not found: <path> |
1 | Audio decode failure | Error: <decoder message> |
2 | Missing path argument | Error: missing file path |
2 | Unknown command | Unknown command: <cmd> |
Last updated on