In Windows 10 and Windows 8, it is possible to get Hash values for a file without using third party tools. A special cmdlet will allow you to calculate the SHA1, SHA256, SHA384, SHA512, MACTripleDES, MD5, and RIPEMD160 hash values of a given file. Here is how it can be done.
The general purpose of hash values is to ensure that a file is genuine and that its contents have not been changed by a third-party, another software or malware. When a file has been modified, its hash value also gets modified. It is also possible to compare and match hash values to find if two or more files are identical.
The ability to calculate the file hash is a part of the Windows cryptograpic API. The user interface of the operating system has no option to calculate or show the hash value for files. Instead, you can use Get-FileHash cmdlet in PowerShell. Here is how to use it.
To get the file hash with PowerShell in Windows 10, do the following.
The general syntax for the cmdlet is as follows:
Get-FileHash c:\windows\explorer.exe| Format-List
Open PowerShell and type the command above to test it. It calculates the SHA256 hash value for the given file and produces the output as follows.
To calculate the hash value other than SHA256, use the switch -Algorithm. For example, to get the MD5 hash value, execute the following command:
Get-FileHash c:\windows\explorer.exe -Algorithm MD5| Format-List
The output will be as follows:
The list of possible values for the -Algorithm is as follows:
- SHA1
- SHA256
- SHA384
- SHA512
- MACTripleDES
- MD5
- RIPEMD160
Another useful switch you need to know is -LiteralPath. It specifies the path to a file. Unlike the default path parameter, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcard characters. If the path includes escape characters, enclose the path in single quotation marks. Single quotation marks instruct Windows PowerShell to not interpret characters as escape sequences.
Using the Get-FileHash cmdlet, you can get hash values for a file natively. It is very useful, especially when you are working in a secure environment where third-party software is not allowed. The PowerShell console is bundled with Windows 10 and is accessible in every installed instance, so you can use the native Get-FileHash cmdlet everywhere.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
I love you!
Hi, very helpful, thanks in advance! I like to use just “vanilla” tools and no third-party tools, but post pages refer to some “hash check utilities”. With this simple command, I can easily write my own batch or script to verify the hash :-)
Thanks the complete syntax helped
Thank you, thumbs up