From 38c997e1993559999ae341d676d80b4b40bc4983 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 18 Aug 2026 11:35:31 +0200 Subject: [PATCH] fix: support Chocolatey PowerShell hash verification --- .../chocolatey/tools/DevNavChocolatey.ps1 | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packaging/chocolatey/tools/DevNavChocolatey.ps1 b/packaging/chocolatey/tools/DevNavChocolatey.ps1 index eed6b13..e29c717 100644 --- a/packaging/chocolatey/tools/DevNavChocolatey.ps1 +++ b/packaging/chocolatey/tools/DevNavChocolatey.ps1 @@ -54,10 +54,28 @@ function Assert-DevNavSha256 { [Parameter(Mandatory)][string] $Path, [Parameter(Mandatory)][ValidatePattern('^[A-Fa-f0-9]{64}$')][string] $Expected ) - $actual = (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash + $actual = Get-DevNavSha256 -Path $Path if ($actual -ne $Expected) { throw "SHA-256 mismatch for '$Path'." } } +function Get-DevNavSha256 { + param([Parameter(Mandatory)][string] $Path) + + $stream = [System.IO.File]::OpenRead($Path) + try { + $sha256 = [System.Security.Cryptography.SHA256]::Create() + try { + return ([System.BitConverter]::ToString($sha256.ComputeHash($stream))).Replace('-', '') + } + finally { + $sha256.Dispose() + } + } + finally { + $stream.Dispose() + } +} + function Add-DevNavMachineModulePath { param([Parameter(Mandatory)][string] $PackageTools)