How to decrypt files realtime

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
turconi
Posts: 23
Joined: Tue Feb 17, 2009 1:55 am

How to decrypt files realtime

Post by turconi »

Hi, I'm here again :)


Anybody knows if there's a method to decrypt files while loading them? For example: I encrypt files with XOR and then, I want that irrlicht loads the file and before "process" the file, decrypts it with the XOR code that I wanted.

In what .cpp file can I add the "function" to decrypt the files?

Thanks in advance.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can load the file encrypted into RAM, decrypt completely into a memory area, create a memory Read file from that, and pass the IReadFile to the next methods.
turconi
Posts: 23
Joined: Tue Feb 17, 2009 1:55 am

Post by turconi »

Yes...Irrlicht loads the file and then put it in memory. But where will be the memory? In what file could I add a function to decrypt it?

Sorry I'm a beginner :)

Thanks for the answer.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can do all this in your application. And the encrypted file can come from disk or from an archive or anything the virtual filesystem provides.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

turconi wrote:Yes...Irrlicht loads the file and then put it in memory.
No, Irrlicht creates a file handle that is suitable for reading data from a file. You have to put that data into a block of memory that you can access.
turconi wrote:In what file could I add a function to decrypt it?
You'd put it into a source file, hopefully alongside your encryption function. You shouldn't need to modify any of the existing Irrlicht library code to do this.

If you are using a recent version of Irrlicht, you should consider creating your own derived IArchiveLoader class that knows how to recognize, open and read an encrypted file archive. All you need to do is create an instance of your archive loader and pass it to the file system. Then whenever you try to get a file, you just request it from the file system, and it will be decrypted automagically.

Travis
turconi
Posts: 23
Joined: Tue Feb 17, 2009 1:55 am

Post by turconi »

I talked with a friend that used irrlicht about a year ago, he said that I can load by myself and then decrypt it (by myself too) and use "createImageFromData".
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, if it's just image data this is also a viable way. The ways vitek and I described work also for other data, such as meshes.
Post Reply