Guest User

Sha Hash

a guest
May 9th, 2017
1,644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $file = 'd:\scripts\PSFile.ps1'
  2. $sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider
  3. [System.BitConverter]::ToString( $sha1.ComputeHash([System.IO.File]::ReadAllBytes($file)))
  4.  
  5.  
  6. <# Useful Comments:
  7. If the File size is more than 2 GB , you will get Exception calling "ReadAllBytes" with "1" argument(s): "The file is too long. This operation is currently limiited to supporting files less than 2 gigabytes in size."
  8. It's better to use File.OpenRead instead of trying to load the entire file into memory at once. HashAlgorithm.ComputeHash has an overload for Stream.
  9. #>
Add Comment
Please, Sign In to add comment