Created
October 7, 2024 17:47
-
-
Save cworld1/ace2f133a640df899d2f9479015edb84 to your computer and use it in GitHub Desktop.
A bat script to calc MD5 or SHA1/256 hash for Windows users. No additional requirements need.
This file contains hidden or 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 | |
:: Display a simple logo | |
echo. | |
echo ================================ | |
echo Hash Calculator | |
echo ================================ | |
echo. | |
:loop | |
:: Check if a file path is provided as an argument | |
if "%~1"=="" ( | |
set /p filePath="> Enter file path or drag file here: " | |
) else ( | |
set filePath="%~1" | |
) | |
:: Remove quotes for checking existence | |
set filePathNoQuotes=%filePath:"=% | |
if not exist %filePathNoQuotes% ( | |
echo File does not exist, please re-enter. | |
goto loop | |
) | |
set /p choice="> Enter your choice 1. MD5, 2. SHA1, 3. SHA256(Default): " | |
:: Default to SHA256 if no input | |
if "%choice%"=="" ( | |
set choice=3 | |
) | |
if "%choice%"=="1" ( | |
certutil -hashfile %filePathNoQuotes% MD5 | |
) else if "%choice%"=="2" ( | |
certutil -hashfile %filePathNoQuotes% SHA1 | |
) else if "%choice%"=="3" ( | |
certutil -hashfile %filePathNoQuotes% SHA256 | |
) else ( | |
echo Invalid option, please select again. | |
) | |
echo. | |
goto loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can: