Here's a good encryption system :V
def encrypt(filename)
if FileTest.exist?(filename)
File.open(filename + '.enc', 'wb') {|file| file.print '.'}
end
end
Oh, you also want to be able to decrypt it again? Well... don't use that then >_>
More seriously the problem here is not protecting data from a man-in-the-middle, but rather the tougher problem of allowing the game to use the resources while they are unavailable for the player in other contexts.
What can you do to prevent a hacker using the decryption system provided by the game to decrypt the resources? (Not considering malware as an option)
What you really want is to protect your work.
You already got the copyright since that happens automatically. If possible in your jurisdiction actually registering the copyright will be beneficial. Not just in legal issues, but also as a matter of verifying that you are indeed one of the authors for employers.
The default encryption system however easy it may be to break still sends a clear signal. I haven't heard of any cases where anyone accidentally decrypted the .rgssad and extracted its contents into a file structure.
You can provide clauses in the eula which prevents the end user from decrypting the .rgssad in any other context than what the unmodified game does. You cannot completely forbid decryption of the encrypted archive in the eula because the end user wouldn't be able to play the game otherwise. It will probably be a bit tricky to formulate the eula so that decryption is only allow in the smallest extent required to play the game.
Yes, this is about letting the legal system handle the shortcomings of the technical solution.
When the game is finished I suggest that you create a
production version where you have only what's needed and nothing more. Where you also remove all comments in your scripts and all unneeded comments in the events. (Some event comments may be necessary for some script system. By default no event comments are needed)
It is important that you keep a version which contains the extra information and also keep other resources you used to create the game, but which is not needed in the production version.
Hackers can't extract information from the game which is not present. They can of course try to recreate it, but keeping this extra information will definitely help.
Quote from: ForeverZer0 on December 23, 2010, 06:10:57 pm
Either way, I wouldn't worry to much about people stealing your scripts. No one is actually making money using RMXP, and if you thought the scripts were that good, get a license or copyright to protect your work. Then you can sue them for trillions.
There are people making money using RMXP and I think there are actually a select few who make a living creating commercial RMXP games.
As for the patching question you can modify the following snippet for .rxdata files (except Scripts.rxdata):
alias patch_load_data load_data unless $@
def load_data(filename)
# Check if a patched file exists
if FileTest.exist?(filename)
data = ''
# Read the contents of the file (binary mode)
File.open(filename, "rb") {|file| data = file.read}
# Try to decrypt and load the data
begin
object = Marshal.load(Decrypt::decrypt(data))
rescue
# Malformed file, load from the encrypted archive
return patch_load_data(filename)
end
# Return the object
return object
else
# Load from the encrypt archive
return patch_load_data(filename)
end
end
module Decrypt
def self.decrypt(data)
# Fill this out
end
end
You need to fill out the decryption yourself which should correspond to however you encrypt the files.
You can do something similar if you want to update Scripts.rxdata: (Must be placed in the first section, i.e. as the very first script)
module Decrypt
def self.decrypt(data)
# Fill this out
end
end
if FileTest.exist?('Data/Scripts.rxdata')
data = ''
# Read the contents of the file (binary mode)
File.open('Data/Scripts.rxdata', 'rb') {|file| data = file.read}
# Decompress and load the object
begin
scripts = Marshal.load(Decrypt::decrypt(data))
# Remove the first script (This script)
scripts.shift
# Decompress and evaluate the scripts
for tuple in scripts
script = Zlib::Inflate.inflate(tuple[2])
eval(script)
end
# Exit the game
exit
rescue
# Malformed file => Do nothing
end
end
The
scripts.shift line is only necessary if the script is also present in the patched version.
I included the Decrypt module in both snippets in case you just chose one.
*hugs*