### HASH

#### Synopsis

    HELP:   Hash calculation/verification
    TYPE:   OBJECT
    SYNTAX: > flcl HASH(FILE['str'/STREAM/DUMMY...],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,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.

#### 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

- `STRING: FILE['str'/STREAM/DUMMY...] - Name/URL of file to hash [''==origin.ext]`
  - `STREAM - Read from stdin or write to stdout`
  - `DUMMY - Read EOF or write nothing`
- `NUMBER: ALGO=MD5/RIPEMD128/RIPEMD160/SHA1/SHA224/SHA256/SHA384/SHA512/SHA3-224/SHA3-256/SHA3-384/SHA3-512/CRC8/CRC16/CRC24/CRC32/CRC32C/CRC40/CRC64 - Hash algorithm [SHA1]`
  - `MD5 - Message-Digest Algorithm 5 (128 bit)`
  - `RIPEMD128 - RACE Integrity Primitives Evaluation Message Digest (128 bit)`
  - `RIPEMD160 - RACE Integrity Primitives Evaluation Message Digest (160 bit)`
  - `SHA1 - Secure Hash Algorithm 1 (160 bit)`
  - `SHA224 - Secure Hash Algorithm 2 (224 bit)`
  - `SHA256 - Secure Hash Algorithm 2 (256 bit)`
  - `SHA384 - Secure Hash Algorithm 2 (384 bit)`
  - `SHA512 - Secure Hash Algorithm 2 (512 bit)`
  - `SHA3-224 - Secure Hash Algorithm 3 (224 bit)`
  - `SHA3-256 - Secure Hash Algorithm 3 (256 bit)`
  - `SHA3-384 - Secure Hash Algorithm 3 (384 bit)`
  - `SHA3-512 - Secure Hash Algorithm 3 (512 bit)`
  - `CRC8 - Cyclic Redundancy Check (8 bit)`
  - `CRC16 - Cyclic Redundancy Check (16 bit)`
  - `CRC24 - Cyclic Redundancy Check (24 bit)`
  - `CRC32 - Cyclic Redundancy Check (32 bit)`
  - `CRC32C - Cyclic Redundancy Check (32 bit) Castagnoli variant`
  - `CRC40 - Cyclic Redundancy Check (40 bit)`
  - `CRC64 - Cyclic Redundancy Check (64 bit)`
- `NUMBER: FORMAT=GNU/BSD/HEX/BIN - Define printout format [GNU]`
  - `GNU - Write output in GNU style`
  - `BSD - Write output in BSD style`
  - `HEX - Write output as hexadecimal string`
  - `BIN - Write output as binary value (only in output file)`
- `STRING: OUTPUT='str'/STDOUT/STDERR - Name of the output file [LOG]`
  - `STDOUT - Write output to stdout`
  - `STDERR - Write output to stderr`
- `STRING: MEMBER='str' - Member name in GNU or BSD format [original name at read, target name at write]`
- `NUMBER: BLKSIZ=num - Block size for read operations [65536]`