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. In this article we would learn about computing hashes on command prompt (cmd).

Description of command:
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

Solutie

Pasi de urmat
Certutil -hashfile (Path_to_file) [HashAlgo]

Where Path_to_file is mandatory(should be provided) argument and HashAlgo is optional argument (If not provided, defaults to SHA1). If HashAlgo is provided it should either be from SHA (Secure Hash Algorithms) or from MD (Message Digest) Cryptographic Hash families. Some of the hash algorithms allowed in the command are MD4, MD5, SHA1, SHA256, SHA512.

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

(11 din 18 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?