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

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:
Certutil | Microsoft Docs
CertUtil

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值