Function Hash($strFileName, optional $strHashType)
Dim $objXML, $objXEL, $objHash, $objStream, $BinaryFile
$objStream = CreateObject("ADODB.Stream")
$objStream.Type = 1
$objStream.Open
$objStream.LoadFromFile($strFileName)
$BinaryFile = $objStream.Read
$objStream.Close
$objStream = ""
Select
Case $strHashType = "MD5"
$objHash = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
Case $strHashType = "SHA1"
$objHash = CreateObject("System.Security.Cryptography.SHA1CryptoServiceProvider")
Case $strHashType = "SHA256"
$objHash = CreateObject("System.Security.Cryptography.SHA256Managed")
Case $strHashType = "SHA384"
$objHash = CreateObject("System.Security.Cryptography.SHA384Managed")
Case $strHashType = "SHA512"
$objHash = CreateObject("System.Security.Cryptography.SHA512Managed")
Case 1
$objHash = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
EndSelect
$RC=$objHash.ComputeHash_2($BinaryFile)
$objXML = CreateObject("MSXML2.DOMDocument")
$objXEL = $objXML.CreateElement("tmp")
$objXEL.DataType = "bin.hex"
$objXEL.NodeTypedValue = $objHash.Hash
$Hash = $objXEL.Text
EndFunction
? "Hash: "+Hash("D:\Firefox Setup 46.0.1.exe", "md5")