计算SHA1哈希算法的Powershell V2.0算法、Powershell

2023-09-11 06:28:10 作者:孤独败凉城

有谁知道是否可以计算SHA1哈希在PowerShell中V2.0?

Does anyone know if it is possible to calculate a SHA1 Hash in Powershell V2.0?

唯一的信息,我可以在网上找到的是使用PowerShell V4.0。

The only information I can find online is with Powershell V4.0.

推荐答案

我不记得在PowerShell的V2天,.NET 3.5是典型的安装了。我认为这是这样的。

I can't remember back in Powershell V2 days, .NET 3.5 was typically installed too. I think it's the case.

您可以尝试以下,看看它的工作原理:

You can always try the following and see if it 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 a file you have.

 
精彩推荐