How to Computes the hash value for a file? | Computes MD2, MD4, MD5, SHA1, SHA256, SHA384 and SHA512

Video Guide: Watch on YouTube

What is hash value?
A hash value is a unique value that corresponds to the content of the file. Rather than identifying the contents of a file by its file name, extension, or other designation, a hash assigns a unique value to the contents of a file. File names and extensions can be changed without altering the content of the file, and without changing the hash value. Similarly, the file's content can be changed without changing the name or extension. However, changing even a single character in the contents of a file changes the hash value of the file.
What is the purpose of hash values?
The purpose of hash values is to provide a cryptographically secure way to verify that the contents of a file have not been changed. While some hash algorithms, including MD5 and SHA1, are no longer considered secure against attack, the goal of a secure hash algorithm is to render it impossible to change the contents of a file -- either by accident or by malicious or unauthorized attempt -- and maintain the same hash value. You can also use hash values to determine if two different files have exactly the same content. If the hash values of two files are identical, the contents of the files are also identical.
We can compute hash value using PowerShell and Command Prompt.

Using PowerShell

We can compute SHA1, SHA256, SHA384, SHA512 and MD5 using PowerShell. Because for security reasons, MD5 and SHA1, which are no longer considered secure, should only be used for simple change validation, and should not be used to generate hash values for files that require protection from attack or tampering.
Now, let compute the hash value...
1. Open the location/path/folder of the file of which you want to compute the hash value.
2. Press Shift + right-click and select Open PowerShell window here.
3. Run command according to the required hash value type:
  • For SHA1: get-filehash <file name with extension> -algorithm sha1
  • For SHA256: get-filehash <file name with extension>
  • For SHA384: get-filehash <file name with extension> -algorithm sha384
  • For SHA512: get-filehash <file name with extension> -algorithm sha512
  • For MD5: get-filehash <file name with extension> -algorithm md5
Source: Microsoft

Using Command Prompt

We can compute MD2, MD4, MD5, SHA1, SHA256, SHA384 and SHA512 using Command Prompt.
Now, let compute the hash value...
1. Press the Windows key and type "cmd" and select Command Prompt from results.
2. Run command according to the file location and required hash value type:
  • For MD2: certutil -hashfile <file location>\<file name with extension> md2
  • For MD4: certutil -hashfile <file location>\<file name with extension> md4
  • For MD5: certutil -hashfile <file location>\<file name with extension> md5
  • For SHA1: certutil -hashfile <file location>\<file name with extension>
  • For SHA256: certutil -hashfile <file location>\<file name with extension> sha256
  • For SHA384: certutil -hashfile <file location>\<file name with extension> sha384
  • For SHA512: certutil -hashfile <file location>\<file name with extension> sha512
Source: Microsoft