内容

名称

shasum - 打印或检查 SHA 校验和

语法

Usage: shasum [OPTION]... [FILE]...
Print or check SHA checksums.
With no FILE, or when FILE is -, read standard input.

  -a, --algorithm   1 (default), 224, 256, 384, 512, 512224, 512256
  -b, --binary      read in binary mode
  -c, --check       read SHA sums from the FILEs and check them
      --tag         create a BSD-style checksum
  -t, --text        read in 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,
                        ASCII '1' interpreted as 1-bit,
                        all other characters ignored

The following five options are useful only when verifying checksums:
      --ignore-missing  don't fail or report status for missing files
  -q, --quiet           don't print OK for each successfully verified file
  -s, --status          don't output anything, status code shows success
      --strict          exit non-zero for improperly formatted checksum lines
  -w, --warn            warn about improperly formatted checksum lines

  -h, --help        display this help and exit
  -v, --version     output version information and exit

When verifying SHA-512/224 or SHA-512/256 checksums, indicate the
algorithm explicitly using the -a option, e.g.

  shasum -a 512224 -c checksumfile

The sums are computed as described in FIPS PUB 180-4.  When checking,
the input should be a former output of this program.  The default
mode is to print a line with checksum, a character indicating type
(`*' for binary, ` ' for text, `U' for UNIVERSAL, `^' for BITS),
and name for each FILE.  The line starts with a `\' character if the
FILE name contains either newlines or backslashes, which are then
replaced by the two-character sequences `\n' and `\\' respectively.

Report shasum bugs to [email protected]

说明

运行 shasum 通常是计算 SHA 消息摘要的最快速方法。用户只需通过文件或标准输入将数据馈送到脚本,然后从标准输出收集结果。

以下命令显示了如何为典型输入(例如 NIST 测试向量“abc”)计算摘要

perl -e "print qq(abc)" | shasum

或者,如果你想使用 SHA-256 而不是默认的 SHA-1,只需说

perl -e "print qq(abc)" | shasum -a 256

由于 shasum 模仿了 GNU sha1sumsha224sumsha256sumsha384sumsha512sum 程序的运行方式,因此你可以将此脚本安装为方便的替代方案。

与 GNU 程序不同,shasum 通过允许部分字节输入来涵盖整个 SHA 标准。这通过 BITS 选项 (-0) 来实现。以下示例计算 7 位消息 0001100 的 SHA-224 摘要

perl -e "print qq(0001100)" | shasum -0 -a 224

作者

版权所有 (C) 2003-2023 Mark Shelor <[email protected]>。

另请参阅

shasum 是使用 Perl 模块 Digest::SHA 实现的。