# encoding: ascii
# api: powershell
# title: Hash Checker On One Line
# description: Check and md5 or sha1 hash in a “single line” of PowerShell.
# version: 0.1
# author: Joel Bennett
# license: CC0
# x-poshcode-id: 988
# x-archived: 2016-05-17T14:21:13
# x-published: 2009-04-01T11:55:00
#
#
# to make it readable, I've wrapped the lines, but you can remove all the line breaks:
&{ 
  PARAM($FileName,$HashFileName) 
  ((Get-Content $HashFileName) -match $FileName)[0].split(" ")[0] -eq 
  [string]::Join("", (
    [Security.Cryptography.HashAlgorithm]::Create(
      ([IO.Path]::GetExtension($HashFileName).Substring(1).ToUpper())
    ).ComputeHash( 
      [IO.File]::ReadAllBytes( (Convert-Path $FileName) 
    )
  ) | ForEach { "{0:x2}" -f $_ }))
# Note that the last line here includes the PARAMETERS: FileName and HashFileName
} npp.5.3.1.Installer.exe npp.5.3.1.release.md5
