#=============================================================================== # CRC Checker # By Jet10985 (Jet) #=============================================================================== # This script will perform CRC file integrity checks on specified files to # ensure there's been no alterations or corruption of original files. # This script has: 5 customization options. #=============================================================================== # Overwritten Methods: # None #------------------------------------------------------------------------------- # Aliased methods: # None #=============================================================================== =begin Make sure to turn off LOG_CRC upon release. I recommend not putting in too many files, because it has to load the entire file into memory in order to check it. This is not a completely secure way of preventing alterations, it will only ward off amateurs. =end module Jet module CRCChecker # These are the files to be CRC checked. If you want to log the crc of the # file first, put the name of the file as the first part, and anything # as the next. FILES = { "Game.exe" => 142291674, "System/RGSS301.dll" => 1982872590 } # Do you want to log the crcs of the given files to a .txt file for copying? LOG_CRC = true # Perform CRC checks? CHECK_CRC = false # This is the message that appears if CRC checks fail. FAILURE_MESSAGE = "Integrity checks have failed, please redownload the files or ensure that all files are present." # Should the game close if CRC checks fail? CLOSE_UPON_FAILURE = true end end if Jet::CRCChecker::LOG_CRC file = File.new("CRC.txt", "w+") Jet::CRCChecker::FILES.each_key do |key| file.write "\"#{key}\" => #{Zlib.crc32(File.binread(key))}" file.write ",\n" if Jet::CRCChecker::FILES.keys.last != key end file.close end if Jet::CRCChecker::CHECK_CRC Jet::CRCChecker::FILES.each do |file, key| if !File.exist?(file) || Zlib.crc32(File.binread(file)) != key msgbox Jet::CRCChecker::FAILURE_MESSAGE exit if Jet::CRCChecker::CLOSE_UPON_FAILURE end end end