I can check md5sum hash of a file from a terminal as,
$ md5sum my_sensitive_file
8dad53cfc973c59864b8318263737462 my_sensitive_file
But the difficult part is to compare the hash value with exact one.
It is difficult to compare the 32 characters output with original/exact hash value by any human for a large numbers of files. First of all the job would be very monotonous and there are big scope of errors.
Is it possible to automate the comparing process, preferably in CLI?
For example I have a file called
test_binary
.MD5 sum of file test is
ef7ab26f9a3b2cbd35aa3e7e69aad86c
To test it automatically run this:
or
Quote from man
Quote from wiki
Link to wiki
Also you can just read md5 hashes from file
It is expecting file with format:
About
*
and<space>
after MD5 sum hash. There is little note in man:And here is link to stackoverflow where I found answer on question, why should we, sometimes, distinguish
binary
files andtext
files.One possibility is to use the utility cfv
CFV supports many types of hashes, and both testing and hash file creation.
Yes, asterisk
*
is required for this command. Take a look at this example.This is the binary file, and let say the correct md5sum value is
exampleofcorrectmd5value00000000
(32 hexadecimal char)If the md5sum value match with the binary file, you'll get this output
And this is when the md5sum value doesn't match
Without asterisk
*
, you'll get the following error message even thought the md5 value is correctAlso, you'll get the same error message if md5sum doesn't have 32 hexadecimal characters in it. In this example, it only has 31 characters.
Solution for many files
If you have many files and want to automate the process, you can follow these steps:
Generate md5sum for each files and save it to md5sum.txt
To check md5sum for all files, use the following command.
This is example if the md5sum value doesn't match with the file. In this case, I'm going to modify
file-b
contentSee, this is the error message. Hope this helps.