2016-02-05 49 views
0

由于art.exe(artifactory CLI接口)在我的构建脚本中调用时会挂起,我正在从powershell 2.0中的page on the topic中重写bash脚本。我使用这个代码来生成校验我:如何生成与artifactory相同的校验和?

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

问题是,它始终产生于我的地方不同的校验比artifactory的产生。这不是'传输过程中的错误'错误,因为我在本地生成了校验和,而且我手动部署了好几次。

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

谢谢!

回答

0

你必须使用

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