2021-01-04 IBU UniBe
1
How to generate MD5 checksums and use them to check the integrity
of transferred data
What is a MD5 checksum?
MD5 checksum is a hash function producing a 128-bit hash value. It is widely used in the software
world to provide some assurance that a transferred file has arrived intact.
Linux or Mac:
How to generate an md5 checksum on Linux or Mac
1) open a terminal
2) navigate to the location where the file (some_file.txt) for which you want to generate an
md5 checksum is located
3) type the following command: md5sum some_file.txt > checkmd5.md5
4) to check the content of checkmd5.md5 run: cat checkmd5.md5
you will see something like this:
ee1ee0ab262121c0f9e79f28a76ec8dc some_file.txt
Check integrity of a file using a provided md5 checksum on Linux or Mac
my_large_file.txt: the file that you downloaded and whose integrity you want to check
checkmd5.md5: a file that contains the md5 checksum of my_large_file.txt. It is usually provided by the
party that generated my_large_file.txt (e.g. the sequencing core facility). The file name can differ,
and it can be opened using a text editor, e.g. notepad. In this example, the content of checkmd5.md5
is:
c4c4cb1b8bf1cbd4f112f0bf88a7aeb3 my_large_file.txt
To check if my_large_file.txt is ok after you downloaded it to your computer:
1) open a terminal
2) navigate to the location (the folder) where both files (my_large_file.txt and checkmd5.md5) are
stored
3) type the following command: md5sum -c checkmd5.md5
If my_large_file.txt is ok you will get this message:
my_large_file.txt: OK
If my_large_file.txt is incomplete or corrupted, you will get this message:
my_large_file.txt: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match
2021-01-04 IBU UniBe
2
Windows:
How to generate an md5 checksum on Windows
Command Line:
o Open command prompt (Press Windows+X to open the Power Users menu, and then
click “Command Prompt”) and type:
CertUtil -hashfile <path to file> MD5
Or within explorer:
o Download the program HashCheck (http://code.kliu.org/hashcheck/)
o It integrates file checksumming functionality into Windows file properties dialog:
Within Windows Explorer right click on the file and select properties you will see a
tab containing different check sums including MD5
o Or you can create checksum files:
If you want to create a checksum file, HashCheck adds an optional "Create Checksum
File" command to the shell's context menu. Simply select the files and directories
that you want to hash and create a checksum file for, right-click on them, and select
"Create Checksum File".
Check integrity of a file using a provided md5 checksum on Windows
my_large_file.txt
: the file that you downloaded and whose integrity you want to check
checkmd5.md5
: a file that contains the md5 checksum of
my_large_file.txt
. It is usually provided by the
party that generated
my_large_file.txt
(e.g. the sequencing core facility). The file name can differ,
and it can be opened using a text editor, e.g. notepad. In this example, the content of
checkmd5.md5
is:
c4c4cb1b8bf1cbd4f112f0bf88a7aeb3 my_large_file.txt
2021-01-04 IBU UniBe
3
To check if my_large_file.txt is ok after you transferred it to your computer:
1) Generate the MD5 checksum for my_large_file.txt as described above
2) Compare the obtained MD5 checksum with the one that you were provided with, in this
example the content of checkmd5.md5. To do this you may use a text editor, e.g. notepad, to
open checkmd5.md5 and the use the search function to see if the hashes are identical