add support for sha512 hashes / autoupdate custom hash type support

This commit is contained in:
Rémy
2017-01-01 13:17:55 +01:00
parent 74f62bc4b0
commit 5170cb9185
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -57,13 +57,17 @@ function getHash([String] $app, $config, [String] $version, [String] $url)
$hashfile_url = substitute $config.url @{'$version' = $version; '$url' = $url};
$hashfile = (new-object net.webclient).downloadstring($hashfile_url)
$regex = substitute $config.find @{'$basename' = [regex]::Escape($basename)}
$regex = $config.find
if ($regex -eq $null) {
$regex = "([a-z0-9]+)"
}
$regex = substitute $regex @{'$basename' = [regex]::Escape($basename)}
if ($hashfile -match $regex) {
$hash = $matches[1]
if ($config.type -eq "sha1") {
$hash = "sha1:$hash"
if ($config.type -and !($config.type -eq "sha256")) {
$hash = $config.type + ":$hash"
}
}
} elseif ($hashmode -eq "download") {
+1 -1
View File
@@ -340,7 +340,7 @@ function check_hash($file, $url, $manifest, $arch) {
$type, $expected = 'sha256', $type
}
if(@('md5','sha1','sha256') -notcontains $type) {
if(@('md5','sha1','sha256', 'sha512') -notcontains $type) {
return $false, "hash type $type isn't supported"
}