HASH

Synopsis

HELP:   Hash calculation/verification
TYPE:   OBJECT
SYNTAX: > flcl HASH(FILE['str'/STREAM/DUMMY...],EXCLUDE['str'...],DIR(),LOG(),ALGO=MD5/RIPEMD128/RIPEMD160/SHA1/SHA224/SHA256/SHA384/SHA512/SHA3-224/SHA3-256/SHA3-384/SHA3-512/CRC8/CRC16/CRC24/CRC32/CRC32C/CRC40/CRC64/CRC64XZ/CRC64ECMA/CRC32POSIX/SHAKE128/SHAKE256,CHECK.{},FORMAT=GNU/BSD/HEX/BIN,CUT=num,OUTPUT='str'/STDOUT/STDERR,MEMBER='str',CCSID='str'/DEFAULT/ASCII/EBCDIC/SYSTEM/LOCAL,BLKSIZ=num)

Description

The HASH command calculates or verifies checksums for one or more local or remote input files. Files are read in binary format. Beside hex and binary Checksums in GNU and BSD formats are supported, which are compatible with common tools like 'sha1sum' and 'md5sum' on UNIX systems. This can be useful to verify files transferred between different systems, especially to or from mainframes.

If possible, hardware acceleration is used for hash calculation.

The HASH command prints only minimal log output. For a more verbose output (e.g. statistics), please use the log object (see examples below).

To get syntax information, please use:

   flcl SYNTAX HASH

To get help for the parameters, please use:

   flcl HELP HASH.parameter[.parameter[...]]

To read the manual page for a parameter, please use:

   flcl MANPAGE HASH.parameter[.parameter[...]]
      or
   flcl HELP XCHK.parameter[.parameter[...]] MAN

To generate the user manual for the command, please use:

   flcl GENDOCU HASH=filename

Parameters can be defined via command line (directly or per file) or through properties read from the corresponding property file.

Checksum algorithms

The complete list of supported algorithms with a short description of each is printed by:

   flcl HELP HASH.algo

Beside the cryptographic hashes (SHA-1, SHA-2, SHA-3, MD5, RIPEMD) a set of CRC checksums is available for plain integrity checking. These are not of cryptographic quality and must not be used to protect data against manipulation.

There is no single CRC-64: several parametrisations of the same width are in common use and they produce different values for the same data. Three of them are provided:

For a new setup CRC64XZ is the recommended choice of the three.

For 32 bit there are three as well:

Extendable-output functions

SHAKE128 and SHAKE256 are the extendable-output functions of FIPS 202, the same standard the SHA-3 hashes come from. Unlike a normal digest they have no natural output length: the caller decides how many bytes are produced.

The length is given with the CUT parameter. Without CUT the default is 32 bytes for SHAKE128 and 64 bytes for SHAKE256, which is the length at which each of them reaches its full collision resistance. The largest value that can be requested is 128 bytes.

Because the output is a stream, a shorter value is always the beginning of a longer one. Whether a checksum is produced with CUT=32 directly or taken from the first 32 bytes of a longer one makes no difference.

   flcl hash file=data.bin algo=SHAKE256
   flcl hash file=data.bin algo=SHAKE256 cut=32
   flcl hash file=data.bin algo=SHAKE128 cut=100

These values can be reproduced outside FLAM with 'openssl dgst -shake256 -xoflen 32' and comparable tools.

Examples

Calculate the checksum using the default hash algorithm (SHA1) for the file "fileToBeHashed.exe" in default format (GNU) to the default output file (LOG).

   flcl hash file=fileToBeHashed.exe

Calculate the checksum using SHA-512 hash algorithm for the remote file "fileToBeHashed.exe".

   flcl hash file=ssh://<cuser>@server1/fileToBeHashed.exe algo=sha512

Calculate the checksum using SHA-512 hash algorithm for the file "fileToBeHashed.exe" and write the result to the file "outhash.txt".

   flcl hash file=fileToBeHashed.exe algo=sha512 output=outhash.txt

Calculate the checksum using SHA-512 hash algorithm for the file "fileToBeHashed.exe" and write the result to the file "outhash.txt" in IBM-1141 CCSID.

   flcl hash file=fileToBeHashed.exe algo=sha512
      CCSID=IBM-1141 output=outhash1141.txt

Verify the file "fileToBeHashed.exe" using SHA-512 hash algorithm by comparing to the checksum stored in file "outhash.txt".

   flcl hash file=fileToBeHashed.exe algo=sha512 check.file=outhash.txt

Calculate the checksum using SHA-512 hash algorithm for the file "fileToBeHashed.exe". Print log output with the default filter (more output information)

   flcl hash "file=fileToBeHashed.exe algo=sha512 log(message(default))"

If you want to get the hash value of the decompressed content of a file without decompressing it to a temporary file, please take a look at the XCHK command. It is a much more powerful command to analyze input files.

Arguments