SHA-384 is a cryptographic hash function that can be used for file integrity verification. For example, to check that the file has not been altered during transfer over the network. This tutorial demonstrates how to generate and verify SHA-384 hash of file in Linux.
Generate SHA-384 hash
For testing purpose, create a new file:
printf 'Hello world' > test.txt
Linux provides sha384sum
command for generating and verifying SHA-384 hash. In order to generate SHA-384 hash of file and print result in the terminal, use the following command:
sha384sum test.txt
Output:
9203b0c4439fd1e6ae5878866337b7c532acd6d9260150c80318e8ab8c27ce330189f8df94fb890df1d298ff360627e1 test.txt
We can write result to a file by using >
redirection operator:
sha384sum test.txt > test.sha384
Verify SHA-384 hash
We can verify file integrity using -c
option:
sha384sum -c test.sha384
Output:
test.txt: OK
Append additional text to change content of a file:
printf 'Hi' >> test.txt
Verify SHA-384 hash of a file again. We get the following output:
test.txt: FAILED
sha384sum: WARNING: 1 computed checksum did NOT match
Leave a Comment
Cancel reply