Created
January 9, 2024 08:46
-
-
Save R00tFS/dc2692ce147a1cb36f78c00f152d6226 to your computer and use it in GitHub Desktop.
Script to calculate hash of a GOF2 save file hash
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
import hashlib | |
# read file data as bytes | |
file = open("gof2_save_game_", "rb+") | |
data = file.read() | |
def calculate_hash(data) -> bytes: | |
# secret key to calculate the hash | |
key = b"#+\xc2\xa7R0LL3r(0aSter&_%=$+#\x00" | |
# create hash object | |
hash = hashlib.sha256() | |
# Update hash with the save by excluding old hash | |
hash.update(data[:-32]) | |
# Update hash with the secret key | |
hash.update(key) | |
# return the hash | |
return hash.digest() | |
# seek to the end of the file before hash | |
file.seek(len(data)-32) | |
# write the hash | |
file.write(calculate_hash(data)) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment