| Crypto |
|
Encrypting flash content has been around for a while now, but normally it is because people being worried about their actionscript being stolen. Another valueble asset all games have are the graphics. Without these you basically don't have a game. So I figured that it might be nice if people could encrypt the images that came with their game and then decrypt them at run-time. This would have a number of advantages:
I've written a AS2 class - Crypto - which enables such decrypting and encrypting. All you have to do is pass it a BitmapData object and it will return the encrypted bitmap. Then you can pass it this encrypted bitmap and it will decrypt it.
You can download the source files here.
Example 1: import flash.display.BitmapData; This code will create a bitmap from the symbol in the library with linkage "image2". It then creates an encrypted bitmap and saves it, and finally, decrypts the encrypted bitmap to a new bitmap. Then it displays all three:
As you can see the encrypted image is totally unrecognisable, with all the pixels jumbled up. But then it is reconstructed perfectly to the third image.
To use this class just create a new instance of the crypto class and then call the encryptBmp and decryptBmp methods. Both these methods return a bitmap.
WARNING: May take a while to process large images.
Example 2: import flash.display.BitmapData; This example will create an image which will encrypt/decrypt when clicked. You can test it out below:
|
Crypto