Generate and Verify SHA-224 Hash of File in Linux

Generate and Verify SHA-224 Hash of File in Linux

SHA-224 is a cryptographic hash function that can be used for verifying file integrity. For example, to check that the file has not been modified during transfer over the network. This tutorial explains how to generate and verify SHA-224 hash of file in Linux.

Generate SHA-224 hash

Create a new file for testing:

printf 'Hello world' > test.txt

In Linux, the sha224sum command allows to generate and verify SHA-224 hash. Execute the following command to generate SHA-224 hash of file and print result in the terminal:

sha224sum test.txt

Output:

ac230f15fcae7f77d8f76e99adf45864a1c6f800655da78dea956112  test.txt

Use > redirection operator in order to write result to a file:

sha224sum test.txt > test.sha224

Verify SHA-224 hash

File integrity can be verified using -c option:

sha224sum -c test.sha224

Output:

test.txt: OK

Change content of a file by appending additional text:

printf 'Hi' >> test.txt

After SHA-224 hash of a file was verified again, we get the following output:

test.txt: FAILED
sha224sum: WARNING: 1 computed checksum did NOT match

Leave a Comment

Cancel reply

Your email address will not be published.