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 / Load an encrypted file in memory and use it

User Offline
Joined: 5th Apr 2023
Posted: 5th Apr 2023 13:06 Edited at: 5th Apr 2023 14:20
Do you if it's possible to load/open an encrypted file in memory and use it directly, (without creating a decrypted file,) ?

What I would like :
- I have encrypted file (txt, image)
- I would like to decrypt it in memory
- and use the result directly from the memblock

For the moment, what I do :
- open a file and decrypt it in memblock
- and use CreateFileFromMemblock() to create the decrypted file
- so after, I open the file (ex :with loadimage() if it's an image or opentoread() if it's a txt).
- And I delete the file decrypted.

It's not good for me.
I would like to use the result, directly from memory (I can do that in purebasic).

But I don't know how to do that, and if it's possible.

Do you have an idea how to do that ?

Thank you a lot.

MOD Edit: No Advertising, please.
Years of Service
User Offline
Joined: 9th Oct 2002
Posted: 5th Apr 2023 18:24 Edited at: 5th Apr 2023 18:25
Yes, you can load an encrypted memblock from a file, then decrypt it in memory and then convert it into the media format you need. They key is to write out the memblock(s) using the media format(s) you will want to later import it in.

So the process looks something like:

- Convert all of your media files you want encrypted to memblocks using the relevant commands:
> CreateMemblockFromObjectMesh
> CreateMemblockFromSound
> CreateMemblockFromImage
> CreateMemblockFromFile (text files, data, files, etc)

- Encrypt the memblocks using whatever system you want.

- Save out the now encrypted memblocks to files using CreateFileFromMemblock.

Then on the loading side, you simply reverse the process:

- Load the encrypted memblocks into memory using CreateMemblockFromFile.

- Decrypt the memblocks as needed.

- Convert the now decrypted memblocks to the format needed and place in relevant media indexes you want to use with the needed commands:
> CreateObjectFromMeshMemblock
> CreateSoundFromMemblock
> CreateImageFromMemblock

This way, you never have to save out the memblocks to files before loading them into media indexes. Everything stays in memory.
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Apr 2023 21:40

Login to post a reply

Server time is: 2023-12-04 18:57:34
Your offset time is: 2023-12-04 18:57:34