5723

29 分钟

#Bash 的 sha512sum 命令

sha512sum [OPTION]... [FILE]...

功能

计算或校验 SHA512 值。

类型

可执行文件(/usr/bin/sha512sum),属于 coreutils

参数

  • OPTION 选项:
    • -b, --binary - 以二进制模式读取文件;类 UNIX 系统下始终是二进制模式
    • -c, --check - 从文件中读取 SHA512 值进行校验
    • --tag- 生成 BSD 风格的输出
    • -t, --text - 以文本模式读取文件;类 UNIX 系统下不存在文本模式,此选项无效
    • -z, --zero - 以空字符(\0)作为行的结尾,而不是换行符(\n
    • --ignore-missing - 校验时忽略缺失的文件
    • --quiet - 校验时不打印成功的消息
    • --status - 校验时不打印任何消息;可以通过返回值检查是否成功
    • --strict - 校验时严格检查格式
    • -w, --warn - 校验时遇到格式不正确的行时产生警告
    • --help - 显示帮助
    • --version - 显示版本
  • FILE - 文件列表

#示例

计算 SHA512 值

$ sha512sum 1.txt # 单个文件 65ded19fe8945cba7cd781c9765ea47ef12fc381cfb94dc4114d2608d5e74ececcfb992e601090fe6f2e68e7822b44fcab9ed4d5d33477f0389f067dabcfb6a2 1.txt $ sha512sum 1.txt 2.txt 3.txt # 多个文件 65ded19fe8945cba7cd781c9765ea47ef12fc381cfb94dc4114d2608d5e74ececcfb992e601090fe6f2e68e7822b44fcab9ed4d5d33477f0389f067dabcfb6a2 1.txt c9712f9dc674b4c5541dc744277957e4ec2349bc5a997b082ca379efb7dbdb0622a0c9afd033056f8f1706463c7fff229a79692e38850fd3e17d3e9d087b1849 2.txt db3974a97f2407b7cae1ae637c0030687a11913274d578492558e39c16c017de84eacdc8c62fe34ee4e12b4b1428817f09b6a2760c3f8a664ceae94d2434a593 3.txt $ sha512sum --tag 1.txt 2.txt 3.txt # BSD 风格 SHA512 (1.txt) = 65ded19fe8945cba7cd781c9765ea47ef12fc381cfb94dc4114d2608d5e74ececcfb992e601090fe6f2e68e7822b44fcab9ed4d5d33477f0389f067dabcfb6a2 SHA512 (2.txt) = c9712f9dc674b4c5541dc744277957e4ec2349bc5a997b082ca379efb7dbdb0622a0c9afd033056f8f1706463c7fff229a79692e38850fd3e17d3e9d087b1849 SHA512 (3.txt) = db3974a97f2407b7cae1ae637c0030687a11913274d578492558e39c16c017de84eacdc8c62fe34ee4e12b4b1428817f09b6a2760c3f8a664ceae94d2434a593

校验 SHA512 值

$ sha512sum 1.txt 2.txt 3.txt > sha1.txt $ sha512sum -c sha1.txt # 校验 1.txt: OK 2.txt: OK 3.txt: OK

#相关命令

命令说明
b2sum计算和校验 BLAKE2 值
md5sum计算和校验 MD5 值
sha1sum计算和校验 SHA1 值
sha224sum计算和校验 SHA224 值
sha256sum计算和校验 SHA256 值
sha512sum计算和校验 SHA512 值

#推荐阅读

#手册

SHA512SUM(1) User Commands SHA512SUM(1) NAME sha512sum - compute and check SHA512 message digest SYNOPSIS sha512sum [OPTION]... [FILE]... DESCRIPTION Print or check SHA512 (512-bit) checksums. With no FILE, or when FILE is -, read standard input. -b, --binary read in binary mode -c, --check read checksums from the FILEs and check them --tag create a BSD-style checksum -t, --text read in text mode (default) -z, --zero end each output line with NUL, not newline, and disable file name escaping The following five options are useful only when verifying checksums: --ignore-missing don't fail or report status for missing files --quiet don't print OK for each successfully verified file --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 --help display this help and exit --version output version information and exit The sums are computed as described in FIPS-180-2. When checking, the input should be a former output of this program. The default mode is to print a line with: checksum, a space, a character indicating input mode ('*' for binary, ' ' for text or where binary is insignificant), and name for each FILE. Note: There is no difference between binary mode and text mode on GNU systems. AUTHOR Written by Ulrich Drepper, Scott Miller, and David Madore. REPORTING BUGS GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Report any translation bugs to <https://translationproject.org/team/> COPYRIGHT Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO cksum(1) Full documentation <https://www.gnu.org/software/coreutils/sha512sum> or available locally via: info '(coreutils) sha2 utilities' GNU coreutils 9.4 April 2024 SHA512SUM(1)

创建于 2025/11/2

更新于 2025/11/2