Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Last active March 13, 2021 06:59
Show Gist options
  • Save gsscoder/e22daefaff9b5d8ac16afb070f1a7971 to your computer and use it in GitHub Desktop.
Save gsscoder/e22daefaff9b5d8ac16afb070f1a7971 to your computer and use it in GitHub Desktop.
Batch script to compare a file SHA256 checksum to a given one
@echo off
setlocal enabledelayedexpansion
::Batch script to compare a file SHA256 checksum to a given one.
::Usage: checksum [FILE] [VALUE]
set filepath=%1
set checksum=%2
set idx=0
for /f %%F in ('certutil -hashfile %filepath% SHA256') do (
set "out!idx!=%%F"
set /a idx += 1
)
set filechecksum=%out1%
if /i %checksum%==%filechecksum% (
echo %checksum% validated.
) else (
echo Checksum validation falied.
exit 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment