Last active
April 29, 2021 17:41
-
-
Save andrematias/bc5e900e3571d29236032288dae81c23 to your computer and use it in GitHub Desktop.
Um script basico para gerar um md5 de arquivos e compara-los
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
Param ( | |
$FirstFile = $(throw "Um primeiro arquivo eh requerido"), | |
$SecondFile = $(throw "Um segundo arquivo eh requerido") | |
) | |
function md5hash($path) | |
{ | |
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider | |
$file = [System.IO.File]::Open($path,[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read) | |
try { | |
Return [System.BitConverter]::ToString($md5.ComputeHash($file)) | |
} finally { | |
$file.Dispose() | |
} | |
} | |
$a = md5hash($FirstFile) | |
$b = md5hash($SecondFile) | |
If ($a -eq $b) | |
{ | |
Write-Host 'OK' | |
} | |
Else | |
{ | |
Write-Host 'NOK' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment