Calculating SHA1 hash algorithm in PowerShell V2.0

后端 未结 2 413
清歌不尽
清歌不尽 2021-01-18 03:13

Is it possible to calculate a SHA-1 hash in PowerShell V2.0?

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

2条回答
  •  借酒劲吻你
    2021-01-18 03:39

    I can't remember back in PowerShell V2 days if .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.

提交回复
热议问题