- [Narrator] Hi, and welcome to the sixth video
of section two: Checksum and Verification.
In the previous video, we have learned
about translating with TR.
In this video, we'll see how to compute checksums
to verify integrity of data.
Checksum programs are used to generate
checksum key strings from the files
and verify the integrity of the files later
by using that checksum string.
A file might be distributed over the network
or any storage media to different destinations.
Due to many reasons, there are chances
of the file being corrupted due to few data bits missing
during the data transfer by different reasons.
These errors happen most often
while downloading files from the internet,
transferring through a network, CD-ROM damage, and so on.
Hence, we need to know whether the received file
is the correct one or not by applying some kind of test.
The special key string that is used
for this file integrity test is known as a checksum.
We calculate the checksum for the original file
as well as the received file.
By comparing both of the checksums,
we can verify whether the received file
is the correct one or not.
If the checksums calculated from the original file
at the source location and the one calculated
from the destination are equal, it means
that we have received the correct file
without causing any erroneous data loss
during data transfer.
Otherwise, the user has to repeat the data transfer
and try the checksum comparison again.
Checksums are crucial while writing backup scripts
or maintenance scripts that transfer files
through the network.
By using checksum verification,
files corrupted during the data transfer
over the network can be identified,
and those files can be resent again
from the source to the destination.
The most famous and widely-used checksum techniques
are md5sum and SHA-1.
They generate checksum strings by applying
the corresponding algorithm to the file content.
Let's see how we can generate a checksum
from a file and verify the integrity of that file.
Let's see how to do it.
To compute the md5sum, use the following command.
Md5sum is a 32-character hexidecimal string as given.
We direct the checksum output to a file
and use that .md5 file for verification as follows.
The syntax for the md5sum checksum calculation
is as follows.
Where multiple files are used,
the output will contain a checksum
for each of the files, having one checksum string
per line as follows.
The integrity of a file can be verified
by using the generated file as follows.
Or alternatively, if we need to check
all the files using .md5 information available, use.
SHA-1 is another commonly-used checksum algorithm
like md5sum.
It generates a 40-character hex code
from a given input file.
The command used for calculating
a SHA-1 string is sha1sum.
Its usage is very similar to that of md5sum.
Simply replace md5sum with sha1sum
in all the commands previously mentioned.
Instead of file_sum.md5, change the output file name
to file_sum.sha1.
Checksum verification is very useful
to verify the integrity of files
that we have downloaded from the Internet.
For example, ISO images are very susceptible
to erroneous bits.
A few wrong bits in the wrong location,
and the ISO may not be readable.
Therefore, to check whether we received
the file correctly, checksums are widely used.
For the same file data, the checksum program
will always produce the same checksum string.
This is the md5sum checksum that's created.
Checksums are also useful when used
with a number of files.
Let's see how to apply checksums
to a collection of files and verify correctness,
checksum for directories.
Checksums are calculated for files.
Calculating the checksum for a directory
would mean that we would need to calculate
the checksums for all the files
in the directory recursively.
It can be achieved by the md5deep or sha1deep command.
Install the md5deep package
to make these commands available.
An example of this command is as follows.
Alternatively, use a combination of find
to calculate checksums recursively.
To verify, use the following command.
Great.
In this video, we have successfully learned
about checksum and verification.
I hope you enjoyed watching this video.
In the next video, we'll learn
about cryptographic tools and hashes.