IBM Support

How to get the MD5 and SHA1 checksum for a file: md5sum, digest, csum, certUtil (sha1sum)

Question & Answer


Question

When interacting with WebSphere MQ (WMQ) Support regarding a file with an interim fix, you were asked to get the MD5 and SHA1 checksum for the file. You want to know how to get the checksum.
.
+ Note about IBM Passport Advantage using SHA1:
When downloading MQ files from IBM Passport Advantage, the download page shows a field named "Checksum". This is NOT based on MD5 but based on SHA1.
The tool to use to compute the checksum is: sha1sum
.
Please see bottom section for more details on SHA1 (sha1sum).

Cause

What is an MD5 checksum?
An MD5 checksum is a 32-character hexadecimal number that is computed on a file.
The MD5 checksum or digest or hash has been widely used in the software world to provide some assurance that a transferred file has arrived intact. For example, file servers often provide a pre-computed MD5, so that a user can compare the checksum of the downloaded file to it
If two files have the same MD5 checksum value, then there is a high probability that the two files are the same.
After downloading an MQ software installation package, you can compute the MD5 checksum on the installation file.

The MD5 checksum or MD5 hash is a more secure alternative to the checksums obtained from the "sum" or "cksum" commands. The sum and cksum commands are file integrity utilities that are based on a weak cyclic redundancy check mechanism (32-bit wide), and this mechanism is prone to high collision rates.

Answer

For illustration purposes, a file from one machine was copied as file "binary.file" into a network shared drive, then the following tests were performed to obtain the MD5 checksum on different platforms.
In all cases the MD5 checksum for this file is: 0c4627e70d168f7f78257e6dd01fdb60

LINUX: md5sum fileName

In Linux, the md5sum utility can be used:
aemtux1:/ % md5sum binary.file
0c4627e70d168f7f78257e6dd01fdb60 binary.file

This utility is provided by the following rpm package (the package name is the key element, because the version number depends on your Linux installation)
% rpm -qf /usr/bin/md5sum
coreutils-5.2.1-23.13


AIX: csum -h MD5 fileName

In AIX, there is no native "md5sum" but the MD5 hash function is provided by csum (provided and supported in AIX 5.3 and later):
csum -h MD5

aemaix1:/ % csum -h MD5 binary.file
0c4627e70d168f7f78257e6dd01fdb60 binary.file

Note: You may need to apply fixes to AIX for csum to handle files larger than 2 GB. For example:
IV03170: csum to support files more than 2GB APPLIES TO AIX 6100-07


Solaris: digest -a md5 -v fileName

In Solaris there is no native "md5sum", but "digest" can be used:

aemsun4:/ % digest -a md5 -v binary.file
md5 (binary.file) = 0c4627e70d168f7f78257e6dd01fdb60


HP-UX: md5sum fileName

HP-UX MD5 Secure Checksum
Product details & specifications
Overview
The HP-UX MD5 Secure Checksum A.01.01.02 bundle (bundle name MD5Checksum) provides a file integrity utility and API based on the standard Message Digest 5 (MD5) algorithm. The MD5Checksum bundle consists of the following two components that can be installed independently:
- HP-UX MD5sum (md5sum checksum command)
- HP-UX LibCryptX (libcryptx libraries providing MD5 APIs)
The md5sum command is based on the MD5 algorithm and generates 128-bit message digests. The md5sum command enables you to verify the integrity of files downloaded over a network connection. You can also use the md5sum command to compare files and verify the integrity of files.


HP NonStop Server (NSS): md5sum fileName

In HP NonStop Server, the md5sum command is available in OSS.


Windows: certUtil -hashfile [pathToFileToCheck] MD5

Newer versions of Windows include a utility called "certUtil".

To create an MD5 for C:\Downloads\binary.file, open a command prompt as administrator and enter:
certUtil -hashfile C:\Downloads\binary.file MD5

This utility can be used to create various SHAs as well.
HashAlgorithm choices: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

For more information on this utility see the following technical article from Microsoft:
https://technet.microsoft.com/en-us/library/cc732443(v=ws.11).aspx
CertUtil
+++ About SHA1 (sha1sum)
++ Windows
.
https://support.microsoft.com/en-us/help/889768/how-to-compute-the-md5-or-sha-1-cryptographic-hash-values-for-a-file
How to compute the MD5 or SHA-1 cryptographic hash values for a file
.
+ begin excerpt
.
You can use the File Checksum Integrity Verifier (FCIV) utility to compute the MD5 or SHA-1 cryptographic hash values of a file. For additional information about the File Checksum Integrity Verifier (FCIV) utility, click the following article number to view the article in the Microsoft Knowledge Base:
https://support.microsoft.com/en-us/help/841290
841290 Availability and description of the File Checksum Integrity Verifier utility
.
To compute the MD5 and the SHA-1 hash values for a file, type the following command at a command line:
FCIV -md5 -sha1 path\filename.ext
.
For example, to compute the MD5 and SHA-1 hash values for the Shdocvw.dll file in your %Systemroot%\System32 folder, type the following command:
FCIV -md5 -sha1 c:\windows\system32\shdocvw.dll
.
+ end excerpt
.
.
++ Linux
.
In RHEL it is provided by the fileset coreutils
$  which sha1sum
/bin/sha1sum
.
$ rpm -qf /bin/sha1sum
coreutils-8.22-23.el7.x86_64
.
.
++ HPe NSS
.
The utility "sha1sum" is provided by the fileset coreutils.
In recent HPe NSS builds, the fileset coreutils is installed by default and the full path for sha1sum is:
/usr/coreutils/bin/sha1sum
.
Note that the coreutils are a requirement as per
https://www-01.ibm.com/common/ssi/ShowDoc.wss?docURL=/common/ssi/rep_sm/9/897/ENUS5724-A39/index.html&request_locale=en#Header_9
5724-A39 IBM MQ for HPE NonStop V8.1
IBM United States Sales Manual
.
+ begin excerpt
.
MQ for HPE NonStop V8.1 was tested with the following Software Product Releases (SPRs) installed. IBM recommends that these SPRs are installed on the system before installing MQ.
...
NSI J06.20
...
T1202AAG Coreutils
.
+ end excerpt
.

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSFKSJ","label":"WebSphere MQ"},"Component":"Install \/ Migration","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.1;9.0;8.0;7.5;7.1;7.0;6.0;5.3.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSYHRD","label":"IBM MQ"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":" ","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Product Synonym

WMQ MQ MQSeries

Document Information

Modified date:
11 September 2019

UID

swg21496703