如何生成与 artifactory 相同的校验和?

How can I generate the same checksum as artifactory?

由于 art.exe(人工 CLI 接口)每当我从我的构建脚本中调用它时都会挂起,我正在 powershell 2.0 中从他们的 page on the topic 重写 bash 脚本。我正在使用此代码生成我的校验和:

$sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider
$path = Resolve-Path "CatVideos.zip"
$bytes = [System.IO.File]::ReadAllBytes($path.Path)
$sha1.ComputeHash($bytes) | foreach { $hash = $hash + $_.ToString("X2") }

$wc=new-object System.Net.WebClient
$wc.Credentials= new-object System.Net.NetworkCredential("svnintegration","orange#5")
$wc.Headers.Add("X-Checksum-Deploy", "true")
$wc.Headers.Add("X-Checksum-Sha1", $hash)

问题是它始终在我的本地生成与人工生成的校验和不同的校验和。这不是 'corruption during transmission' 错误,因为我在本地生成校验和并且手动部署了好几次。

我如何以与 artifactory (2.6.5) 相同的方式生成校验和,以便在我发送我的校验和时我们的校验和匹配并且部署不会失败?我在生成校验和时是否做错了什么?

谢谢!

你必须使用

$wc.Headers.Add("X-Checksum-Sha1", $hash.ToLower())