Computing the SHA1 Hash Algorithm in PowerShell V2.0

Can I calculate the SHA-1 hash in PowerShell V2.0?

The only information I can find on the Internet is PowerShell V4.0.

+8
algorithm powershell hash sha1
source share
2 answers

I cannot remember in PowerShell V2 the days when .NET 3.5 was usually installed. I think this is right.

You can always try the following and see if this works:

$file = 'd:\scripts\sha1.ps1' $sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider [System.BitConverter]::ToString( $sha1.ComputeHash([System.IO.File]::ReadAllBytes($file))) 

Replace the value of $file with the name of the file you have.

+23
source share

Yes, it is possible, as it is part of NET 2.0. In fact, PowerShell Community Extensions use .NET hash support to implement Get-Hash . Version 2.1.1 installs and runs on PowerShell V2.

+1
source share

All Articles