![](/img/trans.png)
[英]How to concatenate video files from different sub directories using ffmpeg in win10 command prompt?
[英]Win10 - How to pipe the output from one command as an argument of another to check file hash?
假设我需要根据网站提供的 hash 验证文件的 md5 hash。
我使用certutil -hashfile.\amazon-corretto-11.0.10.9.1-windows-x64.msi md5
或Get-FileHash -Path.\amazon-corretto-11.0.10.9.1-windows-x64.msi -Algorithm md5
powershell 得到 hash,然后我从下载网站上查看 hash,逐字比较。 有没有办法让命令行进行比较?
我试过certutil -hashfile.\amazon-corretto-11.0.10.9.1-windows-x64.msi md5 | echo == "website_hash"
certutil -hashfile.\amazon-corretto-11.0.10.9.1-windows-x64.msi md5 | echo == "website_hash"
,但它没有用。
欢迎使用命令行和 powershell 解决方案。
继续我的评论。 尝试这个:
Get-FileHash -Path 'D:\temp\book1.txt' -Algorithm MD5 |
Format-Table -AutoSize
# Results
<#
Algorithm Hash Path
--------- ---- ----
MD5 D572724F26BD600773F708AB264BE45B D:\temp\book1.txt
#>
$CompareObjectSplat = @{
DifferenceObject = (Get-FileHash -Path 'D:\temp\book1.txt' -Algorithm MD5).Hash
ReferenceObject = (Get-FileHash -Path 'D:\temp\book1.txt' -Algorithm MD5).Hash
}
Compare-Object @compareObjectSplat -IncludeEqual
# Results
<#
InputObject SideIndicator
----------- -------------
D572724F26BD600773F708AB264BE45B ==
#>
# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-FileHash).Parameters
(Get-Command -Name Get-FileHash).Parameters.Keys
Get-help -Name Get-FileHash -Examples
Get-help -Name Get-FileHash -Full
Get-help -Name Get-FileHash -Online
(Get-Command -Name Compare-Object).Parameters
(Get-Command -Name Compare-Object).Parameters.Keys
Get-help -Name Compare-Object -Examples
Get-help -Name Compare-Object -Full
Get-help -Name Compare-Object -Online
根据 mklement0 对您的有用回复和您的后续查询对此进行标记。
# Command line - executable
(certutil -hashfile 'D:\temp\book1.txt' md5)
# Results
<#
MD5 hash of D:\temp\book1.txt:
d572724f26bd600773f708ab264be45b
CertUtil: -hashfile command completed successfully.
#>
(certutil -hashfile 'D:\temp\book1.txt' md5)[1] -eq (certutil -hashfile 'D:\temp\book1.txt' md5)[1]
# Results
<#
True
#>
根据@postanote 和@mklement0 的回答,这里有2 个用于非常归档hash 的powerpershell 单行代码,它们都忽略了案例。
证书实用程序:
(certutil -hashfile ./amazon-corretto-11.0.10.9.1-windows-x64.msi MD5)[1] -eq ("EE569A19016F233B2050CC11219EBBFD")
获取文件哈希:
Compare-Object -ReferenceObject (Get-FileHash -Path '.\amazon-corretto-11.0.10.9.1-windows-x64.msi' -Algorithm MD5).Hash -DifferenceObject ("EE569A19016F233B2050CC11219EBBFD") -IncludeEqual
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.