← 返回命令列表

Linux command

shasum 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Calculate SHA-1 hash

shasum [file]

Calculate SHA-256 hash

shasum -a 256 [file]

Calculate SHA-512 hash

shasum -a 512 [file]

Check hashes from file

shasum -c [checksums.txt]

Calculate hash from stdin

echo -n "[text]" | shasum

Binary mode

shasum -b [file]

Create checksums for multiple files

shasum -a 256 [*.tar.gz] > [SHA256SUMS]

说明

shasum is a unified Perl-based utility for computing and verifying SHA message digests across all algorithm variants. The -a option selects the algorithm: SHA-1 (default), SHA-224, SHA-256, SHA-384, SHA-512, and the truncated SHA-512/224 and SHA-512/256 variants. SHA-256 is the most commonly used for software distribution verification and security applications. In check mode (-c), shasum reads a file containing previously generated checksums and verifies each listed file against its recorded hash, reporting success or failure. Output format shows the hash followed by the filename, with BSD-style output (--tag) additionally including the algorithm name. Both formats are understood during verification. This command is the standard SHA utility on macOS and systems with Perl installed, providing equivalent functionality to the separate sha1sum, sha256sum, and sha512sum commands found in GNU coreutils.

参数

-a _ALG_
Algorithm (1, 224, 256, 384, 512, 512224, 512256).
-b
Binary mode.
-c, --check
Check hashes from file.
-t
Text mode (default).
-U, --UNIVERSAL
Read in Universal Newlines mode (produces same digest on Windows/Unix/Mac).
-0, --01
Read in BITS mode (ASCII '0' interpreted as 0-bit, '1' as 1-bit).
-s, --status
Status only, don't output anything (with -c).
--ignore-missing
Don't fail or report status for missing files (with -c).
-q, --quiet
Don't print OK for each successfully verified file (with -c).
-w, --warn
Warn about improperly formatted checksum lines.
--strict
Exit non-zero for improperly formatted lines.
--tag
BSD-style output including algorithm name.
-h, --help
Show help.

FAQ

What is the shasum command used for?

shasum is a unified Perl-based utility for computing and verifying SHA message digests across all algorithm variants. The -a option selects the algorithm: SHA-1 (default), SHA-224, SHA-256, SHA-384, SHA-512, and the truncated SHA-512/224 and SHA-512/256 variants. SHA-256 is the most commonly used for software distribution verification and security applications. In check mode (-c), shasum reads a file containing previously generated checksums and verifies each listed file against its recorded hash, reporting success or failure. Output format shows the hash followed by the filename, with BSD-style output (--tag) additionally including the algorithm name. Both formats are understood during verification. This command is the standard SHA utility on macOS and systems with Perl installed, providing equivalent functionality to the separate sha1sum, sha256sum, and sha512sum commands found in GNU coreutils.

How do I run a basic shasum example?

Run `shasum [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a _ALG_ do in shasum?

Algorithm (1, 224, 256, 384, 512, 512224, 512256).