Saturday, April 16, 2011

Fun with Encryption

A friend of mine was working on a CD he wanted to make, with a bunch of different swf presentations. He wanted to know if its possible to make the various swfs only load up through a single .exe file, and to prevent people from opening up those swfs outside of his main presentation.

This seemed like a very interesting challenge, and I had thought that the only way to do this was to make some c++ program that would encrypt the files and also load them in, save them out as swfs, then somehow send them to the main .exe as swfs, and then delete them when done. However, it turns out there is another way of doing it. This other way that I discovered uses only ActionScript, and now thanks to AIR I was able to make a small app to streamline the process a bit.

The method is best described by the person who (I think) came up with it. You can read about his method here.

I've decided to put the .air file up on my server to share it with others, if they find some need for it.

There are other such apps out there, and likely they work better. However, the project my friend was doing was dealing with over 100 external swfs, and I wanted to be able to do it in a large batch.

The way the program works, is this:  You select an input directory, then you select an export directory.  The program then searches for all swfs in your import directory that don't have the name "enc" in it.  It then turns all these swfs into XML files with the name (yourSwf)_enc.xml  and places those files in the output directory.  Interestingly these XML files are twice the size of the SWF files.  Another time, I'm going to look into making these smaller, or perhaps figureing a better method all together.  In the meantime though, for just a few hours of work, this was way fun, and I thought I would share.