Skip to content

Commit

Permalink
Dev (#13)
Browse files Browse the repository at this point in the history
* Create LICENSE.md (#5) (#6)

* refactor (#7)

* Add readmes (#8)

* readmes

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Console app (#10)

* remove debug output

* add help and basic parameter support

* Add md5 check (#12)

* Update MMRando.py

checksum check

* checksum check
  • Loading branch information
avvie authored Jan 28, 2023
1 parent 7122208 commit 69e2992
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Randomizer/MMRando.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from Generators.PaletteGenerator import PaletteGenerator
from Generators.WeaponGenerator import WeaponGenerator
from Utilities import *
import hashlib
import shutil
import sys
import os.path
Expand All @@ -14,6 +15,7 @@

input_file = "./Mega Man (USA).nes"
output_file = "./MMRando.nes"
supported_md5_input_checksums = ["4de82cfceadbf1a5e693b669b1221107"]

# Gets the path to a valid file passed in arguments, positionally after param
def GetValidFileFromParameter(paramList, param, default = None):
Expand Down Expand Up @@ -46,6 +48,19 @@ def ParamExistsInArgs(paramList, param):
Megaman_Default = [0x2c, 0x11]

try:
# Check for checksum
if os.path.getsize(input_file) >= 150*1024:
print("File too big")
sys.exit(0)

file = open(input_file, "rb")
checksum = str(hashlib.md5(file.read()).hexdigest())
file.close()

if checksum not in supported_md5_input_checksums:
print("Input file md5 checksum not supported " + checksum)
sys.exit(0)

# Make a copy of the original input file
filecopy = shutil.copyfile(input_file, output_file)

Expand Down

0 comments on commit 69e2992

Please sign in to comment.