Encrypting AppData Files using CipherLib
by MoCubed · in Torque Game Builder · 08/29/2010 (10:33 pm) · 1 replies
First off, thanks to everyone who has helped me out so far. I know I usually don't dial back in after I get to the point of solving a problem, but everyone's help has been extremely useful, and I want you to know I'm grateful for these forums.
I have been using the CipherLib resource for a lot of my asset encryption and things have been going fairly well so far. But I have encountered a case in which I want to encrypt data about a particular user's profile, which I'm currently trying to store in the application data directory. I'm not comfortable just leaving the file out there because changing it could give one player an unfair advantage. However, the only workaround I can think of is to just obscure the data using an algorithm of some sort. Not particularly secure, and frustrating because I have this cool encryption tool now and I can't use it for save files.
I've looked at the code for CipherLib itself, and I see that encryptFile() and decryptFile() both use FileStream.open() rather than ResourceManager->openFileForRead() which may be causing the problem. However, I'm not sure exactly how to correct this change, becasue in fileObject.cc, there's no mention of initializing a "stream" object anywhere, so I'm just not all that clear on Torque (read as "any") C++ at all.
The resource can be found here, and if anyone can figure out exactly how to change it to use the look through the resource manager, I'd appreciate it. I'm not sure if the original creator still browses these forums, unfortunately. I'm pretty sure the code you'll want is in Cipher.cc, but I just can't be sure about all the stream requirements, and my build machine is remarkably slow - it's not feasible for me to guess and check here.
Thank you very much.
I have been using the CipherLib resource for a lot of my asset encryption and things have been going fairly well so far. But I have encountered a case in which I want to encrypt data about a particular user's profile, which I'm currently trying to store in the application data directory. I'm not comfortable just leaving the file out there because changing it could give one player an unfair advantage. However, the only workaround I can think of is to just obscure the data using an algorithm of some sort. Not particularly secure, and frustrating because I have this cool encryption tool now and I can't use it for save files.
I've looked at the code for CipherLib itself, and I see that encryptFile() and decryptFile() both use FileStream.open() rather than ResourceManager->openFileForRead() which may be causing the problem. However, I'm not sure exactly how to correct this change, becasue in fileObject.cc, there's no mention of initializing a "stream" object anywhere, so I'm just not all that clear on Torque (read as "any") C++ at all.
The resource can be found here, and if anyone can figure out exactly how to change it to use the look through the resource manager, I'd appreciate it. I'm not sure if the original creator still browses these forums, unfortunately. I'm pretty sure the code you'll want is in Cipher.cc, but I just can't be sure about all the stream requirements, and my build machine is remarkably slow - it's not feasible for me to guess and check here.
Thank you very much.
About the author
Check out our website: www.bakamostudios.com
Torque Owner daffodilistic
Default Studio Name
The only solution that I can think of is - if you're feeling up to it - to code a simple ROT-13 or base64 function in TorqueScript.