Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Batvinks Tutorial - Media Protection Questions.

Author
Message
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 17th Sep 2015 07:14
First of all let me take the time to thank BatVink for his wonderful demonstration in the latest NewsLetter of how to encrypt our media using memblocks. I wish I could offer a real one, but I cant so here you go

I just got done encrypting all my current used media in Age of Knights.
It was a slow process but after a few hours of tinkering around I got it all done.

I created a new file inside the project and called it LoadMedia
Heres what it looks like....




Its not a big issue, but when I'm loading the game on pc. I'm counting 6-7 fast Mississippi(Seconds)
Also watching the appdata folder I can catch 1 or 2 media flash up and delete faster than I can click one...I'm sure if I wanted to I could catch it fast enough...If I tried 100000 times...which if someone wants it that bad they can have it.

The thing I'm worried about is load times on phones. 6 seconds isn't a big deal on a computer for startup times. That 6 seconds may be FOREVER on a phone.

Should I be decrypting a different way or is slow loading the cost of security ?

I have also thought about decrypting the media as it is needed instead of all at once and spreading the time out ....Just looking for options as I'm new to this and wondering about other ways

Thanks for any advice in advance!


For anyone who is intrested in the tutorial you may find it here.
http://www.thegamecreators.com/pages/newsletters/newsletter_issue_151.html

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Sep 2015 10:44
Glad it has helped you out

The first thing I would mention is that the ".png.enc" extension was a quick way for me to demonstrate the code in an understandable way. It might be better to just use ".dat" or something similar so that type of file is also unknown to a would-be hacker.

For images you can also make a huge time saving and improve security (no intermediary file written to disk), but at the cost of disk space. The code is designed to be compatible with any type of file. But if you want to speed up images, you could:

1. Create memblock from image
2. Encrypt
3. Save
...
1. Create Memblock from File
2. Decrypt
3. Create image from memblock

The disk space required is easily calculated, it is essentially a bmp file:

12 + (height * width * 4) bytes.

You can do the same for sound, where you are saving an uncompressed wav file. The difference may be negligible compared to a standard wav file, I'm not familiar with wav compression but I recall it is almost non-existent.

In AAA games, a lot of the wait time is unencrypting and reorganising files and data. Some of the more complex mobile games have longer load times. Worms is probably about 12-15 seconds on my Nexus 4. The secret is misdirection, even a simple progress bar keeps the user informed and less irritable. And counter-intuitively, it gives them the feeling of a higher quality game.

You have a lot of files to load. I would suggest one more thing. List your files in a parameter file or multiple files (one for each media type). Read the files from the parameter file in a loop and load them.
It will streamline your code, make it easier to update your game and you can encrypt the parameter file too so that the file structure cannot be identified either.
A Parameter file module is one of my previous tutorials, and is included in most of the subsequent tutorials too.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Sep 2015 10:56 Edited at: 17th Sep 2015 10:59
This is coding tip that is unrelated to the encryption but ...

All of this:


Could be replaced by this:


Obviously you could also do a similar thing for your FlyTraps, Elements, Monkeys etc.

The only problem you will have is with the filenames like 01, 02 etc. you will either need to change those to get rid of the zero or use my padleft function to put the zero in there.

Either way, it will save you a whole lot of typing!!!

AGK V2 user - Tier 1 (mostly)
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 17th Sep 2015 18:35
Quote: "You have a lot of files to load. I would suggest one more thing. List your files in a parameter file or multiple files (one for each media type). "

I just got done reading your tutorial on this, and I will have to really consider it

Quote: "In AAA games, a lot of the wait time is unencrypting and reorganising files and data."

I just got done converting the whole project over to accept the encrypted files. The Decryption time on the pc is 6 seconds. The Phone was 27 seconds. (Still using the method above)

On a + side when converting the loading method of levels, I have decreased level loading time between screens by 1000% Its almost instant load times now between levels.

I'm not too worried about any further protection (CreateImageFromMemblock) like you mentioned above. I have done my part in taking a small step of Data Protection required by my license terms.

I would assume the ImageFromMemBlock wouldn't be any faster if not slower?

I'm thinking my only options to decreasing the decryption time would be to use an Image Joiner and decrease the amount of encrypted files.

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Sep 2015 20:34
Quote: "I would assume the ImageFromMemBlock wouldn't be any faster if not slower? "


It would be faster. The "standard method" is:

Load file into memblock (slow)
decrypt (fast)
save to disk (slow)
load image (slow)
unpack image from file to AppGameKit format (fast)

Using an image memblock you get:

Load file into memblock (slow)
decrypt (fast)
make image from memblock (fast)

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 17th Sep 2015 20:59
Quote: "It would be faster. The "standard method" is:"

Well then, I will have to do that then...I can spare the disk space and if its faster I should be all over it.

Thanks BatVink for the Tutorials and as always the wonderful advice!

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Sep 2015 21:39 Edited at: 18th Sep 2015 19:28
...

AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Sep 2015 22:38 Edited at: 17th Sep 2015 22:40
Like it says in the tutorial, you can't beat every hacker. If they can steal 47,000 social security numbers and 100 Terabytes of data from Sony, they can steal anything. But you can beat 95% of casual thieves who will steal anything unprotected.

The 2 main things that protect you are:

1. People want to steal the assets from AAA games, this is where they focus their energy.
2. If your media is protected to any degree and there are 1,000 games out there that are not, you are at least 1,001 on the list of assets to steal.

Finally, if your game is so good that people will hack it, you have succeeded as an Indie game maker

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Sep 2015 19:27
@BatVink
yo

AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Sep 2015 22:16
I found a couple of lines that should really be changed. Locate the 2 instances of VAL and replace them with ASC.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-11-25 17:54:31
Your offset time is: 2024-11-25 17:54:31