Defindit Docs and Howto Home
keywords:checksums,digest,dgst,openssl,md5,sha,sha1,sha256,sha384,verify,
description:How to get checksum fingerprints
title:Examples of Linux checksum fingerprints for files: md5, sha.
As input we'll use the date command with nanoseconds. This is not
random and it would be far more clever to figure out how to get a few
bytes from /dev/random.
See this online page:
http://www.fileformat.info/tool/hash.htm?text=2008-03-26+10%3A15%3A05.893623535-04%3A00
The various checksum digest commands have more or less the same
format, except openssl.
md5sum file
openssl dgst -type_of_checksum file
md5sum and similar programs print the checksum and the file name. If
the source was stdin, then the file name is -
Man pages have descriptions, although as of Fedora 8 in 2008, the
openssl has several digests not mentioned in the man page.
Available checksums from openssl seem to be:
md5, md4, md2, sha1, sha, mdc2, ripemd160,
as well as these undocumented digests:
sha256, sha384, sha512
Tab-complete from bash tells me these executables exist:
sha1sum sha224sum sha256sum sha384sum sha512sum
as well as the classic md5sum, and the older (?) cksum and sum.
[zeus ~]$ date --rfc-3339=ns
2008-03-26 10:30:12.586033647-04:00
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | openssl dgst -md5
66eb0dd85a05053ded4e4b94cfa51b26
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | md5sum
66eb0dd85a05053ded4e4b94cfa51b26 -
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | openssl dgst -sha1
b2e4c38153a14517a8290569ea860634001d4de3
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | sha1sum
b2e4c38153a14517a8290569ea860634001d4de3 -
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | openssl dgst -sha512
1b79e25e115affa870d7aeef06990b01b4df4a343f22b3a52cd1050a95da10839f60ce1a1475e6d6c9d8831b471a489c98d82e0a09b3632d7b68a3dff78402cc
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | sha512sum
1b79e25e115affa870d7aeef06990b01b4df4a343f22b3a52cd1050a95da10839f60ce1a1475e6d6c9d8831b471a489c98d82e0a09b3632d7b68a3dff78402cc -
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | cksum
467202395 35
[zeus ~]$ echo -n "2008-03-26 10:30:12.586033647-04:00" | sum
02721 1
[zeus ~]$
I'm not entirely clear about cksum and sum, but they seem to be rarely used.
Several utilities such as md5sum have a mode to verify files. To run
the check you (or someone giving you files) runs md5sum and gives you
the file of the results. The check is performed by running md5sum in
--check mode using the file of the results. Here is a somewhat trivial
example. I've made a new directory, copied some Perl scripts into the
new directory. I ran md5sum on the originals, then cd'd to the
copy_dir and checked the copies.
[zeus ~]$ mkdir copy_dir
[zeus ~]$ cp -av *.pl ./copy_dir/
`fix4cols.pl' -> `./copy_dir/fix4cols.pl'
`modify_user.pl' -> `./copy_dir/modify_user.pl'
`rev.pl' -> `./copy_dir/rev.pl'
`test_del.pl' -> `./copy_dir/test_del.pl'
`tmp.pl' -> `./copy_dir/tmp.pl'
`try.pl' -> `./copy_dir/try.pl'
[zeus ~]$ md5sum *.pl > check_us.txt
[zeus ~]$ cd copy_dir/
[zeus copy_dir]$ md5sum --check ../check_us.txt
fix4cols.pl: OK
modify_user.pl: OK
rev.pl: OK
test_del.pl: OK
tmp.pl: OK
try.pl: OK
[zeus copy_dir]$