Tutorial :AS3 and hashing


Is it possible to hash flv videos so it is unplayable by itself and the format is unrecognizable by softwares, but i could actually de-hash them and play in my as3 script?

This is going to be realized on a CD so I can't use server scripts.


no, you can't. not with flv. you could however embed the video into an swf and encrypt the SWF. please note however, using a strong encryption for video data may lead to performance problems.

anyhow: you can load the binary data into a ByteArray, perform the decryption and then load the SWF from the ByteArray.


I'm assuming you mean that you'd like to do this "real time" in the app.

If so, there are two issues with that:

  1. you will have to decrypt your custom video in software, so its going to run very slow. And depending on the end user's computer, unpredictably so.

  2. As ALOToverflow previously mentioned, the key to your hashing algorithm will be in your .swf which can be simply be decompiled to reveal it.

Assuming you are using as3 with adobe AIR you could potentially ship your users "broken" flv's and then simply repair them before you attempt to play them back.

Depending on the resolution and length of the videos this might be a viable alternative.

(you'd utilize the FileStream Class for this.) http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html

FLV's all start with a standard header, so you could start by just breaking the header, and repairing it later. (I'm talking about getting down and dirty with the binary code btw.) http://en.wikipedia.org/wiki/Flash_Video


I created a similar project once. this is what I did:

I encrypt the videos somehow, does not mater how, put them into one single big file. A bulk data file. Then I run the swf, NOT from browser but rather run it from a JAVA application, which can decrypt the bulk video-file waaay faster, than the Adobe swf interpreter. In the Java app, I pass the decrypted video to the swf as a parameter. It is good to use Java, because all the clients can open it. Mac users, Windows users, anyone. It is possible to do it with C++, but that would limit your user-base.

Of course anyone with decent knowledge can reverse-engineer the encryption process, but it is harder to get the encryption from a Java compiled software, than from an AS3 swf.

Use Blowfish, Twofish or DES. Do not use RSA, it is slow. You have to make the Java app extremely fast and simple, so also it is advised, not to use external cryptography libraries.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »