@credcli/hash
v0.1.0
Published
Calculate IPFS CIDv0 hashes from strings, buffers, or files — no IPFS node required
Readme
@credcli/hash
Calculate IPFS CIDv0 hashes from strings, buffers, or files — no IPFS node required.
Install
npm install @credcli/hashCLI
# Hash a string
credcli-hash "hello world"
# Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD
# Hash a file
credcli-hash --file ./document.pdf
# Hash from stdin
echo -n "hello world" | credcli-hash --stdinLibrary
import { hashString, hashBuffer, hashFile } from '@credcli/hash'
const cid = await hashString('hello world')
// => "Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD"
const cid2 = await hashBuffer(Buffer.from('hello world'))
// => "Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD"
const cid3 = await hashFile('./document.pdf')
// => "Qm..."Notes
- Returns CIDv0 (
Qm...prefix, base58btc-encoded SHA-256 multihash) - Deterministic — same input always produces the same CID
- Uses ipfs-only-hash under the hood
