Monday, 1 May 2017

Generating a File Hash

Sometimes there is a need to generate a hash for a specific file.  Maybe this is so you can assure others that the file is the original, maybe you want to compare it to a file you've downloaded, and sometimes you may need to enter a file hash into some software (e.g. Whitelisting).

There are tools you can download to do this, but handily PowerShell has a command that will do all this for you.  The command is simply "Get-FileHash":

Get-FileHash [-Path] <String[]> [-Algorithm <String>] | Format-List

Where:

  • -Path is simply the path of the file for which you want to generate a hash
  • -Algorithm is the specific hash you want to generate (defaults to SHA256), possible parameters for this option are:
    • SHA1
    • SHA256
    • SHA384
    • SHA512
    • MACTripleDES
    • MD5
    • RIPEMD160