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.

Newcomers AppGameKit Corner / Image ecnrypted (and memoryblock)

Author
Message
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 17th Apr 2016 14:36
Hi

In one of my games, I use image encrypted (AGK2 tier1 basic).
For the moment, the technic i use is simple:
- I decrypt the image, save it (as temporary image) on the harddisk, load it with loadimage(), and delete the image, and go to the next.
But it's not very secure.

So I would like to know how I can do without creating the temporary image on the harddisk.
I have though to use CreateImageFromMemBlock'), but it doesn't work.
I'm looking for a way to "decrypt the image in the memory and load it from the memory" for example.
An idea on how i can do that ?

Thanks .
AGK2 tier1 - http://www.dracaena-studio.com
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 17th Apr 2016 16:41 Edited at: 17th Apr 2016 16:42
It seems to work like the Dbpro commands, where you needed to write the header data into the mem block, followed by the raw data. Images have a header of 3 integers (12 bytes), the first integer is the width (offset 0), followed by the height (offset 4) and then the depth (offset 8).

Scary Little Rabbit added an example to the CreateImageFromMemblock page.

One thing that’s worth noting though, is that the encryption tends raise the entropy on the data set, meaning encrypted data compresses poorly. An alternative might not ne encryption at all, rather to rearrange the it. For things like animations you can cache common strips/blocks, pull out ‘null’ pixels, mixed with some abstract shuffles (transposition) of all the data or some of it. So it’s fast to build the texture at runtime and will compress better in your final release.

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Apr 2016 20:40
Write a small program to encrypt your media:

1. CreateMemblockFromImage()
2. Encrypt memblock
3. SaveMemblock()

In your final game:

1. LoadMemblock
2. Decrypt memblock
3. CreateImageFromMemblock()

The image files will be the same size as a BMP image : (width * height * 4) + 12 bytes.

You can view more in my tutorial here.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 18th Apr 2016 08:48 Edited at: 18th Apr 2016 09:00
@Kevin Picone& Batvink :
thanks for the informations.

But I think the files will be too much big...
For the moment, I use PNG compressed, I don't want to have a game with 100 Mo of images instead of my current 8 Mo ^^.
So, it seems AppGameKit doesn't have a feature to load an image directly in the memory.
AGK2 tier1 - http://www.dracaena-studio.com
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Apr 2016 01:59 Edited at: 19th Apr 2016 02:00
you could encrypt them and then compress them in a .zip file. then use the ExtractZip command to extract them
adambiser
AGK Developer
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 19th Apr 2016 06:50
Using a zip would be even better if it has the ability to extract into a memblock rather than to a file that then has to be read into a memblock.
Fascimania http://www.fascimania.com
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Apr 2016 08:52
if the file have been encrypted it doesn't matter if it extracts it to disk (which it does)
adambiser
AGK Developer
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 20th Apr 2016 17:18
I know it doesn't matter really, but reading directly into a memblock eliminates the need to write and delete files each time the program starts.
Fascimania http://www.fascimania.com
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Apr 2016 22:42
it would be a nice feature and i think it's been requested

Login to post a reply

Server time is: 2024-11-24 00:08:09
Your offset time is: 2024-11-24 00:08:09