Created
March 10, 2017 14:52
-
-
Save dragonfoxsl/fa086bec2e195136266832f73bf81367 to your computer and use it in GitHub Desktop.
Small utility to compare hash values of a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Declared Variables | |
$LineBreak = "="*102 | |
$LineSeperator = "-"*102 | |
$Spacer = " " | |
#Script Header | |
Write-Host $LineBreak | |
Write-Host "------------------------------------------COMPARE HASH FILES------------------------------------------" | |
Write-Host $LineBreak | |
Write-Host $Spacer | |
#Request Inputs from User | |
$HashValue = Read-Host -Prompt 'Input the Hash Value ' | |
$HashAlgo = Read-Host -Prompt 'Input the Hash Algorithm (Ex: SHA1,SHA256,MD5) ' | |
$FileLocation = Read-Host -Prompt 'Enter File Location ' | |
Write-Host $Spacer | |
#Get Hash From File Specified File | |
$hashFromFile = Get-FileHash -Path $FileLocation -Algorithm $HashAlgo | |
asdasd = asdsa | |
#Compare The File Hash with Input Hash | |
#If Hashes Are Equal | |
if ($hashFromFile.Hash -eq $HashValue) { | |
Write-Host $LineSeperator | |
Write-Host ("{0} IS VALID" -f $HashAlgo) | |
Write-Host $LineSeperator | |
Write-Host $Spacer | |
Write-Host "Hash Value : $HashValue" | |
Write-Host ("Hash File : {0}" -f $hashFromFile.Hash) | |
Write-Host ("File Path : {0}" -f $hashFromFile.Path) | |
Write-Host $LineSeperator | |
} | |
#If Hashes Are Not Equal | |
if ($hashFromFile.Hash -ne $HashValue) { | |
Write-Host $LineSeperator | |
Write-Host ("{0} IS INVALID" -f $HashAlgo) | |
Write-Host $LineSeperator | |
Write-Host $Spacer | |
Write-Host "Hash Value : $HashValue" | |
Write-Host ("Hash File : {0}" -f $hashFromFile.Hash) | |
Write-Host ("File Path : {0}" -f $hashFromFile.Path) | |
Write-Host $LineSeperator | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment