I take no credit for this, it was posted on the other site, so I'm posting it here:
Note you can name the .bat whatever you like, I named mine "SHA256.bat"
Would be nice if we had a game dev section (like the VIP section, but for game devs) where we could post this stuff..
shark_inna_hat said:Because of Reasons (see top of the page) - You all might be wondering how to get a file HASH, what it even is and why you might want to share it with your players each time you do a release.
What is a HASH?
I'm too lazy to write technical details myself so here's what Geepyti wrote:
A file hash is a unique string of characters that is generated by a mathematical algorithm (such as SHA256 or MD5) based on the contents of a file. It's like a digital fingerprint for the file. Even a tiny change in the file content will result in a completely different hash value.
File hashes are commonly used in computer security and verification processes. For example:
In essence, a file hash serves as a reliable way to confirm the authenticity and integrity of a file.
- Data Integrity: By comparing the hash of a file before and after transmission, you can ensure that the file has not been altered during transfer.
- Verification: Software downloads often come with a hash value provided by the creator. You can generate the hash of the downloaded file and compare it with the provided hash to verify that the file has not been tampered with.
- Password Storage: In security systems, passwords are often stored as hash values rather than plaintext. This adds an extra layer of security because even if someone gains access to the hash values, they cannot easily reverse-engineer them to obtain the original passwords.
Why you should share it?
If you give your player the hash of your zip (installer) they can easily check if the file they downloaded is the file you shared.
How to generate a Hash??
You could open up powershell, type in a bunch of code... or use this:
Save it asCode:@echo off setlocal enabledelayedexpansion :: Check if a file is dropped onto the batch file if "%~1"=="" ( echo Please drop a file onto this batch file to calculate its hash. pause exit /b ) :: Get the full path of the dropped file set "file=%~1" :: Get current timestamp for /f "tokens=2 delims==." %%a in ('wmic OS Get localdatetime /value') do set "timestamp=%%a" :: Format timestamp set "timestamp=%timestamp:~0,4%-%timestamp:~4,2%-%timestamp:~6,2%_%timestamp:~8,2%-%timestamp:~10,2%-%timestamp:~12,2%" :: Use PowerShell to calculate the hash for /f "delims=" %%H in ('powershell.exe -command "(Get-FileHash '%file%' -Algorithm SHA256).Hash"') do set "hash=%%H" :: Print hash to screen echo Hash SHA256: echo %hash% :: Use PowerShell to write the hash, filename, and timestamp to file powershell.exe -command "$hash = '%hash%'; $timestamp = '%timestamp%'; $filename = '%file%'; Write-Output \"Hash SHA256:`n$hash`n`nFile:`n$filename`n`nTimestamp:`n$timestamp\" | Out-File -FilePath '%file%.hash.txt' -Encoding utf8" echo Hash written to "%file%.hash.txt" pause
gib_me_hash_mr_shark.bat
and just drag'n'drop your file onto it. It will print out the Hash to the console and also write a file that has the hash, timestamp and name of the file all in one place for your pleasure.
Let's make the net a safer place, so please always add the hash in your changelog, so that I know I'm pirating the real deal
P.S. bat file written by AI. Sorry, not sorry, Me===Lazy.
P.P.S. :bat file corrected to be less stupid... because of AI, now it writes the actual filename not 'filename.txt' -_-'
Note you can name the .bat whatever you like, I named mine "SHA256.bat"
Would be nice if we had a game dev section (like the VIP section, but for game devs) where we could post this stuff..