hash_file
Compute a cryptographic or non-cryptographic checksum of a file on disk and optionally verify it against an expected digest.
Instructions
Checksum a file on disk, optionally verifying it against an expected digest.
Crypto digests stream the file in 1 MiB chunks; CRC/xxh/fnv read it whole.
When expected is supplied, verified reports whether it matches the digest
(compared as bytes, so case/0x/whitespace differences are tolerated).
Returns {algorithm, digest, path, size}, plus verified when expected is
given.
Example: hash_file("/etc/hostname", "sha256") -> {digest, path, size, ...}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Filesystem path of the file to checksum. | |
| algorithm | No | Digest algorithm: crypto (md5/sha1/sha2/sha3/blake2*), CRC (crc8/16/32/32c/64), xxhash, or fnv1a_*. shake_* is excluded (no `length` arg). Default 'sha256'. | sha256 |
| expected | No | Expected digest to verify against, in `output_format`; case/`0x`/whitespace tolerated. Default None skips verification. | |
| output_format | No | How the digest is rendered (bare hex, no 0x); default 'hex'. | hex |