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

2 comments:

  1. Wow thanks for this helpful post, I'm sure this was very useful for all programmers and amateurs like me who are still learning this. Keep up the good work.

    ReplyDelete
  2. Thank you for posting this here. Sometimes algorithms for seemingly simple tasks can be so tricky. Please keep posting other programming tips on the blog.

    ReplyDelete