How to Work With File Checksums

Checksums are alphanumeric character sequences produced by running files through an algorithm. They are especially helpful in verifying file integrity since small changes in files can result in significant checksum differences.

One example of a way checksums are helpful can be to ensure your backup files are uncorrupted. By doing so, you will gain an additional layer of security– if anything goes wrong with your site, you can restore it from files that are known to be undamaged.

Generating a Checksum

You can generate a checksum for any file by accessing the command line on your server. Use SSH to connect to your account (See “Connect to My Server With SSH”), then generate the checksum as follows:

md5sum file > checksum.txt

The above command will generate a checksum file called “checksum.txt” using the MD5 algorithm. Another commonly used checksum algorithm is SHA, a general term for a group of similar algorithms such as SHA-256 and SHA-512. 

SHA algorithms are denoted separately due to the varying length of the hash value’s bit length. For example, SHA-256 will be SHA with a 256-bit length.

How to Verify Checksums

Generating the checksum is only half of the job done. Once the file moves for any reason, it should be verified. To verify your file checksum, connect to your server again via SSH and type the following instruction;

md5sum -c checksum.txt

The result of this check will either be an “OK” or “FAILED.” Failed checksums mean there is a problem with the file integrity. While the difference may be minor, it can also be challenging to tell the exact problem.

If your file fails a checksum verification, you should discard the file and transfer a fresh copy. Then, you must rerun the checksum verification.

Rado

Author

Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.

Write a Comment

Required*