Skip to Content
CLImonolith hash

monolith hash

Compute the SHA-256 fingerprint of a file plus a perceptual hash when the file kind is recognized.

monolith hash <path|-> [--json]
ArgumentDescription
<path>File path. Use - to read bytes from stdin.
--jsonEmit a single JSON object instead of key=value lines.

What it computes

KindDetected viaExtra hashAlgorithm
Imagemagic bytesphash64-bit pHash via @stabilityprotocol.com/phash — same as the API
Audiomagic byteschromaprintAcoustID-compatible Chromaprint via rusty-chromaprint-wasm
Otherfingerprint 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.524

JSON 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:

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

ExitCauseStderr
1File not foundError: File not found: <path>
1Audio decode failureError: <decoder message>
2Missing path argumentError: missing file path
2Unknown commandUnknown command: <cmd>
Last updated on