# Verifies that cPicture.exe matches its .sha256 checksum file. # Usage: .\verify-sha256.ps1 [path\to\cPicture.exe] param( [string]$ExeFile = "cPicture.exe" ) $sha256File = $ExeFile + ".sha256" if (-not (Test-Path $ExeFile -PathType Leaf)) { Write-Error "'$ExeFile' 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 $ExeFile -Algorithm SHA256).Hash.ToUpper() if ($actual -eq $expected) { Write-Host "OK $ExeFile" -ForegroundColor Green Write-Host " SHA256: $actual" exit 0 } else { Write-Host "ERROR $ExeFile" -ForegroundColor Red Write-Host " Expected: $expected" Write-Host " Actual: $actual" exit 1 }