1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

cksum: add --raw option to output a binary digest

--raw output is the most composable format, and also is a
robust way to discard the file name without parsing (escaped) output.

Examples:

  $ cksum --raw -a crc "$afile" | basenc --base16
  4ACFC4F0

  $ cksum --raw -a crc "$afile" | basenc --base2msbf
  01001010110011111100010011110000

  $ cksum --raw -a sha256 "$bfile" | basenc --base32
  AAAAAAAADHLGRHAILLQWLAY6SNH7OY5OI2RKNQLSWPY3MCUM4JXQ====

* doc/coreutils.texi (cksum invocation): Describe the new feature.
* src/digest.c (output_file): Inspect the new RAW_DIGEST global,
and output the bytes directly if set.
* src/cksum.c (output_crc): Likewise.
* src/sum.c (output_bsd, output_sysv): Likewise.
* tests/misc/cksum-raw.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
This commit is contained in:
Pádraig Brady
2023-02-03 16:34:18 +00:00
parent 2984e47c78
commit ead07bb3d4
9 changed files with 144 additions and 10 deletions

View File

@@ -4059,6 +4059,17 @@ input digest string as what is output. I.e., removing or adding any
@opindex --debug
Output extra information to stderr, like the checksum implementation being used.
@item --raw
@opindex --raw
@cindex raw binary checksum
Print only the unencoded raw binary digest for a single input.
Do not output the file name or anything else.
Use network byte order (big endian) where applicable:
for @samp{bsd}, @samp{crc}, and @samp{sysv}.
This option works only with a single input.
Unlike other output formats, @command{cksum} provides no way to
@option{--check} a @option{--raw} checksum.
@item --untagged
@opindex --untagged
Output using the original Coreutils format used by the other