Archive of May 2010

May 25, 10

Embedding Private Keys in SWF files

I've recently came across the new online SWF, Zend, and Java decomplier at showmycode.com that allows you to almost "view the source" of the SWF file online. If you had some important data stored in your SWF (such as API keys or passwords) you may not wish them being exposed.
The easiest (and therefore naïve) way to hide them* would be to store them in external text files and embed in the SWF.

[Embed(source="api_key.txt", mimeType="application/octet-stream")]
private const API_KEY:Class;

// ...

var myAPI_KEY:String = String(new API_KEY());

Then you can create an instance and cast it to String, like shown above.

The asset class extends mx.core.ByteArrayAsset and its byte content is not revealed by most decompilers.

*Of course, this "solution" does not offer any serious protection, you can still decompress the SWF and view the keys in the hex editor. You could scramble/hash them a bit to make the hacker's job harder but it's still possible to extract them.

12:46 PM | | 2 Comments | Tags: , ,
May 01, 10

Flash Bokeh

Sometimes your best efforts to convince clients to originality end up in the trash... but on the other hand there is nothing wrong with it – just shake the dust off and share. This time it's the colourful realtime bokeh effect inspired by this tutorial and programmed for tictoc as a proof-of-concept demo.

Flash AS3 Bokeh

Click the image above to preview. Due to expensive alpha and blending processing it may slow down your browser/computer a bit. I've tried two approaches there:

  1. Adding and removing circles to the display list (with cacheAsBitmap turned on).
  2. Drawing circles onto (transparent and non-transparent) bitmap using draw() method.

Both methods eat similar processor time. Haven't tried using any GPU wmodes, not sure if that would help at all here, I'll leave it to you - the code is very simple and there's a lot of room for improvements and optimisations.

Considering the recent HTML5 vs Flash war, the challenge is to code a similar effect using JS + HTML5's canvas and compare the speed – is anyone up for it?

Grab the source (AS3, Flash CS4 was used to tween the circle shapes but you could entirely use drawing API if needed) and enjoy!

11:00 AM | | 4 Comments | Tags: , ,