Advertisement
easternnl

Calculate MD5 Hash of file

Feb 15th, 2016
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Get-MD5
  2. {
  3.     Param([string[]]$string)
  4.  
  5.     $md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
  6.     $hash = [System.BitConverter]::ToString($md5.ComputeHash($string))
  7.  
  8.     return $hash    
  9. }
  10.  
  11. $md5 = Get-MD5([System.IO.File]::ReadAllBytes("C:\windows\fonts\arial.ttf"))
  12. write-host $md5
  13.  
  14. if ($md5 -eq "FE-6B-41-F2-C2-D2-C7-65-5E-C1-E4-45-20-66-7A-14")
  15. {
  16.     write-host "Equal"
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement