hash

When you download an update or move a file between servers, a digest helps check whether the bytes are the same. hash <file> prints the SHA-256 digest alone, which makes comparison and copying easy. hash -s "text" calculates a digest from literal text. A hash does not hide or encrypt that text.

SecurityVersion 1.1.4Stable
lil-terminal

Overview

Choose -a to use another algorithm available in PHP, or -b to display Base64 instead of hexadecimal. Use hash -c <digest> <file> to compare an expected digest with the actual file. A matching digest proves only that bytes match the expected value, not that the person publishing the value can be trusted.

A digest and an HMAC answer different questions

A plain hash detects whether data changed, but anyone who has the data can calculate the same value. HMAC adds a secret key to the check. Neither operation encrypts the input or makes its contents recoverable from the digest.

Syntax

lil-terminal
hash [<file>|-s "<text>"] [-a <algo>] [-h|-K <file>] [-b] · hash -c <digest> <file> [-b]

Reference

hash

list available hashing algorithms

hash <file>

calculate a SHA-256 file hash

hash -s "<text>"

calculate a string hash; quote text that contains spaces

hash <file> -a sha512

select another algorithm

hash <file> -h

calculate HMAC with a hidden key prompt

hash <file> -K <keyfile>

calculate HMAC with a key file

hash -c <digest> <file>

verify a hexadecimal digest

hash -c <digest> <file> -b

verify or print Base64 instead of hexadecimal

-b

output Base64 rather than hexadecimal

Notes

Minimum supports hashing one file or a text string; algorithm selection, verification and HMAC need Base.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Compare SHA-256 and SHA-512

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install hash
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install hash -m
Exact public version

Install exactly this published version.

install hash -v 1.1.4
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade hash
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install hash -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Compare SHA-256 and SHA-512
hash
Available algorithms depend on the PHP server. Example excerpt:
adler32      haval128,5  haval256,5  sha1        snefru256
crc32        haval160,3  joaat       sha3-224    tiger128,3
crc32b       haval160,4  md2         sha3-256    tiger128,4
crc32c       haval160,5  md4         sha3-384    tiger160,3
…
Calculate a SHA-256 file hash
hash \sandbox/feed.xml
fecb9e779e2de5637918deca5ea1bfde9059833a67ed38146e3360944bc06000
Calculate a string hash; quote text that contains spaces
hash -s "HELLO WORLD!"
bf96648169ba89c284b3e94108074c7d5e5806c7b9498031aceded5ca139ed69
Select another algorithm
hash \sandbox/feed.xml -a sha512
b1326264154960b4eb6fb685521ac40de967749c9dd11cc00da69e2d8f2a88b969ecef723d9da4c86945ad407571ec62e3e9cc12bcb2070a0f1e14802ffe5fc3
Output Base64 rather than hexadecimal
hash \sandbox/feed.xml -b
/sued54t5WN5GN7KXqG/3pBZgzpn7TgUbjNglEvAYAA=
Calculate a string hash; quote text that contains spaces
hash -s "hello" -a sha512 -b
m3HSJL1i83hdltRq0+o9czGb+8KJDKra4t/3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw==
Calculate HMAC with a key file
hash \sandbox/feed.xml -K \sandbox/keys/hash.key
09ada086ae48552d1f2c31e2339694927d88b4510e4de75d5099980deb77398b
Calculate HMAC with a key file
hash -s "hello" -K \sandbox/keys/hash.key
fe8e9832244f6150d4d9655df350647f8efff014774fe0f2b10d1a7fcec449ce
Reject a missing file
hash \sandbox/feed.xml -h
A hidden password or key prompt opens. The secret is not echoed.
Verify a hexadecimal digest
hash -c fecb9e779e2de5637918deca5ea1bfde9059833a67ed38146e3360944bc06000 \sandbox/feed.xml
Status     Verified
Algorithm  sha256
Verify or print Base64 instead of hexadecimal
hash -c /sued54t5WN5GN7KXqG/3pBZgzpn7TgUbjNglEvAYAA= \sandbox/feed.xml -b
Status     Verified
Algorithm  sha256
Verify a hexadecimal digest
hash -c 0000000000000000000000000000000000000000000000000000000000000000 \sandbox/feed.xml
Hash mismatch
Verify a hexadecimal digest
hash -c 1234 \sandbox/feed.xml
Invalid hexadecimal digest
Calculate a SHA-256 file hash
hash \sandbox/missing.txt
File not found
Select another algorithm
hash \sandbox/feed.xml -a invalid
Hash algorithm is unavailable
Calculate HMAC with a key file
hash \sandbox/feed.xml -K \sandbox/keys/missing.key
Key file is not readable
Calculate HMAC with a hidden key prompt
hash -s "hello" -h
A hidden password or key prompt opens. The secret is not echoed.
Calculate a SHA-256 file hash
hash \sandbox/feed.xml -z
Unknown option

File used in this example: sandbox/data/sample.txt

The example uses a file or directory from the protected /sandbox/ documentation workspace.

lil-terminal sandbox text file

This file is safe to read, copy, rename, replace, hash and archive.

Related documentation

Current public release

v1.1.42026-08-12

Bare hash inventory

Typing hash alone now lists available algorithms; the redundant -l flag is removed.