计算SHA1哈希算法Powershell V2.0

use*_*898 8 algorithm powershell hash sha1 powershell-2.0

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

我在网上找到的唯一信息是Powershell V4.0.

Mic*_*lli 23

我记不起在Powershell V2时代,.NET 3.5也经常被安装.我认为就是这样.

您可以随时尝试以下操作,看看它是否有效:

$file = 'd:\scripts\sha1.ps1'

$sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider
[System.BitConverter]::ToString( $sha1.ComputeHash([System.IO.File]::ReadAllBytes($file)))
Run Code Online (Sandbox Code Playgroud)

将值替换为$file您拥有的文件的名称.