Game Development Community

Encryption Using Cipher Lib - C++ Newbie

by Alebrije Estudios · in Torque Game Builder · 06/18/2010 (1:50 pm) · 2 replies

I am having a problem using the Cipher Lib, I am following all the http://tdn.garagegames.com/wiki/Torque_2D/Asset_Encryption

I am not being able to mofify the game/main.cc. At approximatly line 120 there to add the ResourceManager->registerExtension(".xpng", constructCipherBitmapPNG); instructions. up tp this point everything compiles properly. Meaning I can add the console function to the script main .cs registerCipherPngExtension(".xpng");


After this part I dont understand exactly where the instrcutions are taking me? Everything I add to the solution doesn't work??

How am I going to use it to change my png files to xpng ?? I understand torque will automatically understand the xpng files when I create the datablocks?

Can anyone help me in a walk through?


thanks

About the author

Alebrije Estudios is a Mex. independent vid game studio. We have 3 main lines of business: in-house developments w/ projects published in the iTunes St., FB, & looking 4 Publisher; advergames; & outsourcing of creative processes. @mike_alebrije


#1
06/18/2010 (5:40 pm)
Reading the article, I think that you are done at that point.

The next section is if you want to add another file type, type JPEG.

The section after that is if you want to implement your own encryption algorithm (which I assume you won't want to do).

At least that's my impressions from the article.
#2
06/21/2010 (1:58 am)
Hi,

have you added the c++ source files from this resource to your visual studio project and verified that everything compiles without errors?

If so, it should be possible to register the "xpng" extension with the console function as you mentioned.

The next step would be to encrypt one of your png files with the cipher tool as described here:
tdn.garagegames.com/wiki/Torque_2D/Asset_Encryption#Encrypting_Files_with_the_Ci...
You must use the same password, encryption algorithm, and encryption mode that are defined at the beginning of "CipherBitmap.h". Of course you can modify these values to your needs (but don't forget to recompile).

You can use the cipher-tool from the console or in a script file. Mind that the article is from a few years ago when TGB still allowed for writing files to arbitrary directories. You might have to search around a bit for the files written by the cipher-tool. It will probably be somewhere in the AppData directory of your user-directory in Windows 7/Vista.

Just be sure to give the encrypted file the filename-extension you registered earlier ("xpng" in the example). This is how the resource manager determines which file-loader to use.

A little disclaimer: This code resource was updated the last time in 2007 with another version of Visual Studio and -more importantly- with another version of TGB. It might not work out of the box any more. Also be sure to read this blog entry and decide if it's really worth the trouble to encrypt your assets. Even with the library to help you it will create some extra work to set up the art pipeline and you'll have another dependency in your code.

-Michael