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 / Encrypt Media Folder

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 15th Feb 2016 10:54
Hi.

If I want Encrypt media folder for secure files, how can do it?

Thanks.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 15th Feb 2016 11:18
you can encode the files with a self made tool,
decode at loading temporary or decode in memblocks CreateMemblockFromFile,CreateImageFromMemblock,CreateSoundFromMemblock
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 15th Feb 2016 12:39
Is there any other programs outside of AppGameKit that uses memblocks?

I've never saved a file as a memblock. Would it have any extension to it (like .mem)?
Or it's just saved using a file name that we specify (without any extension)?
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 15th Feb 2016 13:12
Here are 2 areas that you can try with regard to code snippets for encryption:

1) In the V2 Feature Requests sticky, on page 2 there is some code plus useful posts by Naphier.

2) In the Newsletter no. 151, Sept 2015, Steve Vink posted an article on encryption/decryption with example code.

These should get you started.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 15th Feb 2016 13:24
Quote: "Would it have any extension to it (like .mem)?"

CreateFileFromMemblock
CreateMemblockFromFile

i would try .dat = Data or .bin = binary
not all extensions can used for android from within agk.

AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 27th Feb 2016 18:46
Thanks all.

I don't understand one thing. when AppGameKit make an APK file , we can change .APK to ZIP and seen all contents in media folder. I need know when we changed APK to ZIP, (Images, Sounds, ...) are encrypted or not?

Thanks.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 27th Feb 2016 18:53
There is no encryption in APK and ZIP files.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 27th Feb 2016 19:16 Edited at: 27th Feb 2016 19:16
Quote: "There is no encryption in APK and ZIP files."


is it only for codes?

is there any way to encrypt files in AppGameKit?
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 27th Feb 2016 19:27
Quote: "is there any way to encrypt files in AppGameKit?"

Not built in.You will have to write your own encryption routine which will take in an asset, encrypt it and save it back out. Then load it back in, and decrypt it to use it.

The now defunct newsletter had an article on exactly this of you search for it.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 28th Feb 2016 10:38
Quote: "is there any way to encrypt files in AppGameKit?"

Yes, but nothing built in.

Quote: "you can encode the files with a self made tool"

Quote: "You will have to write your own encryption routine"

Quote: "Steve Vink posted an article on encryption/decryption with example code"


If you convert an image to a memblock, you can apply any encryption you like, but you will have to write the code to do the encryption and decode.

Pseudo:
Loadimage
create memblock from that image
encrypt the new memblock (with your own function)
save the encrypted memblock

In your game:

Load encrypted memblock
decrypt memblock (with your own function)
create image from memblock

Hopefully we will see media folder encryption built into a future release, where can can just set a key at compile time. That would be SO nice!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 28th Feb 2016 12:21
Don't forget to delete the image after its loaded to memory
Download My Games for Android. Made with AGK.
Jellyfish Dive- https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Brick Destroyer - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_BrickDestroyer
Ping Bong - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_Pong_Ping_Bong
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Feb 2016 07:39
Quote: "Don't forget to delete the image after its loaded to memory "


is your mean that after loaded to memory, before Make APK file delete Images?
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 29th Feb 2016 18:24
//////////////////////////Load Bird////////////////////////////////
decryptFile("Bird1.png.enc", "Bird1.png")
BirdFrame1 = LoadImage ("Bird1.png")
DeleteFile ("Bird1.png")
//////////////////////////////////////////////////////////////////////

First you need to decrypt the memblock.
Store the image to memory
Then delete the file so its no longer in your media folder. If you do not delete the file it will be there for anyone to take.


So after its decrypted, stored and deleted you can use BirdFrame1 to create your sprites.

Bird = CreateSprite(BirdFrame1)
Download My Games for Android. Made with AGK.
Jellyfish Dive- https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Brick Destroyer - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_BrickDestroyer
Ping Bong - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_Pong_Ping_Bong
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 29th Feb 2016 18:36 Edited at: 29th Feb 2016 18:36
Quote: "Then delete the file so its no longer in your media folder."

If you use CreateImageFromMemblock() then the image is never written to the hard drive and you don't have to load or delete it.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Feb 2016 19:10
https://www.thegamecreators.com/pages/newsletters/newsletter_issue_151.html#10
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Feb 2016 19:15
OK, Thanks All for help.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Feb 2016 19:16 Edited at: 29th Feb 2016 19:19
OK, Thanks All for help.

Sorry for two post, My internet have problem.
Shizki
21
Years of Service
User Offline
Joined: 24th Apr 2003
Location: UK
Posted: 1st Mar 2016 23:33
I really think this should be built-in as standard, where all assets are automatically encrypted/decrypted.

It would also be really useful if the Export Settings were saved when exporting to iOS/Android.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 2nd Mar 2016 01:51 Edited at: 2nd Mar 2016 08:28
SEE ATTACHED
I made a couple of encryption functions to convert an image file (.png etc) to an encrypted file (That can be loaded directly into an image)
It uses integers to xor the memblock so it's fairly fast (Not awesome but decent)
You would still need to zip your encrypted images as they end up quite large. However the combination of encryption+agk's internal image format makes for a decent encryption i think

Right now it uses SetRawWritePath(GetReadPath()) so generated files go to the media directory.

Would be great if you guys could give it a thorough testing

Sign up for NaGaCreMo!

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 2nd Mar 2016 05:18
if TGC add this feature to AppGameKit it make useful.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 3rd Mar 2016 17:37
I've developed a complete system for loading encrypted, compressed assets (except streaming ones).

Also, I made a tool to generate a single data file which you deploy with your app. It's all a bit rough at the moment, but I would like to release it at some point.

Login to post a reply

Server time is: 2024-11-25 10:22:32
Your offset time is: 2024-11-25 10:22:32