在PowerShell V2.0中计算SHA1哈希算法 [英] Calculating SHA1 hash algorithm in PowerShell V2.0

查看:203
本文介绍了在PowerShell V2.0中计算SHA1哈希算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在PowerShell V2.0中计算SHA-1哈希?

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

我唯一可以在线找到的信息是PowerShell V4.0。

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

推荐答案

如果通常也安装了.NET 3.5,我将不记得在PowerShell V2中。我认为是这种情况。

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)))

$ file 的值替换为您拥有的文件名。

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

这篇关于在PowerShell V2.0中计算SHA1哈希算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆