# Verifies that a cPicture MSI or ZIP package matches its .sha256 checksum file. # Usage: .\verify-sha256.ps1 [path\to\cPicture.msi|path\to\cPicture.zip] param( [string]$PackageFile = "" ) if ([string]::IsNullOrWhiteSpace($PackageFile)) { $PackageFile = @("cPicture.msi", "cPicture.zip") | Where-Object { Test-Path $_ -PathType Leaf } | Select-Object -First 1 } if ([string]::IsNullOrWhiteSpace($PackageFile)) { Write-Error "No cPicture.msi or cPicture.zip found." exit 1 } $sha256File = $PackageFile + ".sha256" if (-not (Test-Path $PackageFile -PathType Leaf)) { Write-Error "'$PackageFile' not found." exit 1 } if (-not (Test-Path $sha256File -PathType Leaf)) { Write-Error "'$sha256File' not found." exit 1 } # Format: " " $line = (Get-Content $sha256File -Encoding ASCII).Trim() $expected = $line.Split()[0].ToUpper() $actual = (Get-FileHash $PackageFile -Algorithm SHA256).Hash.ToUpper() if ($actual -eq $expected) { Write-Host "OK $PackageFile" -ForegroundColor Green Write-Host " SHA256: $actual" exit 0 } else { Write-Host "ERROR $PackageFile" -ForegroundColor Red Write-Host " Expected: $expected" Write-Host " Actual: $actual" exit 1 }