Last active
March 13, 2021 06:59
-
-
Save gsscoder/e22daefaff9b5d8ac16afb070f1a7971 to your computer and use it in GitHub Desktop.
Batch script to compare a file SHA256 checksum to a given one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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