Using OpenSSL for hashing and verifying the hashes of a text file

Configurare noua (How To)

Situatie

Solutie

Part 1: Creating a Hash of a Text File with OpenSSL

-Enter the cat Secret_message to display the contents of the file on the screen

cat Secret_message

-Run the following command to hash the text file.

openssl sha256 Secret_message

This command will use the SHA-256 hashing algorithm to generate a hash of the text file, and the result will be displayed on the screen once OpenSSL completes the computation.

Tip solutie

Permanent

Plan de restaurare in caz de nefunctionare

Part 2: Verifying Hashes

-Let’s edit the Secret_message text file and recalculate the SHA-256 hash. Run the command below to open nano, a command-line text editor.

nano Secret_message

-In nano, change the word “lies” to “dies” on the second line, modifying only one character from ‘l’ to ‘d’. After making the change, save the modified file.

-After modifying and saving the file, run the same command again to generate the SHA-256 hash of the updated file.

openssl sha256 Secret_message

The smallest change results in a completely different hash. Hashes can be calculated before and after transmission, and then compared. If the hashes do not match, then data was modified during transmission.

Voteaza

(10 din 24 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?