Getting hash of a file using CMD

Configurare noua (How To)

Situatie

A cryptographic hash is a fixed size string (or text) that is used as an identifier/fingerprint of some data. These are particularly useful in determining the integrity of files after they are transferred over a communication channel. Hashes are even utilized by certain OS-level processes for their working.

The command processor of Windows OS (cmd.exe) provides the user with the ability to compute hashes on files/Directories via an utility command named Certutil.

Solutie

Pasi de urmat

The command Certutil is primarily used for working with digital certificates and not hashes. The ability to hash files is due to the presence of a -hashfile switch in it.

> Certutil -hashfile
-hashfile  -- Generate and display cryptographic hash over a file

Usage of the command:
To demonstrate the usage of the command, we would be running the command on a file. Our example file will be at the location “C:\Users\Public\spars.txt”.

That contains some text data. So to get the MD5 (Message Digest 5) hash of the file, we would have to execute the command.

certutil -hashfile "C:\Users\Public\spars.txt" MD5

The command upon execution would produce an output similar to this.

MD5 hash of spars.txt:
cb21e6741817a2d3020e02bb94301ae4
CertUtil: -hashfile command completed successfully.

To get SHA512 hash of the above file the command and the output would appear as following:

Tip solutie

Permanent

Voteaza

(3 din 4 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?