Archive for the ‘DATA’ Category
A great Action Message Format (AMF) remoting kit for server side for the pythonistas is pyAMF, they recently released PyAMF 0.3 and have a sample running up on Google App Engine. There is also a tutorial for getting PyAMF running on Google App Engine. Aral Balkan got this running as well.
Features of pyAMF currently:
AMF0 encoder/decoder for legacy Flash Players (version 6-8).- AMF3 encoder/decoder for the new AMF format in Flash Player 9.
- Support for IExternalizable, ArrayCollection, ObjectProxy, ByteArray (with zlib support), RecordSet and RemoteObject
- Remoting gateways for Twisted, Django, TurboGears2, Web2Py, Pylons and any compatible WSGI framework.
- Authentication/setCredentials support
- Remoting client using httplib with authentication support
- Service Browser (DescribeService header) requests supported
- Local Shared Object (LSO) support
- Adapter Framework to integrate nicely with third-party Python projects
More on the PyAMF library:
- Download — Download PyAMF
- Examples — Tutorials and examples
- Features — PyAMF features
- Documentation – General documentation
- Mailing List — Join the mailinglist for user and developer discussions
- Blog — Announcements and news
- IRC Channel — Chat and discuss PyAMF or get support
- Success Stories — See how PyAMF is being used
- Team — The people working on this project
- License — The project is licensed under the open source MIT license
AS3 libraries for crypto are pretty robust from the new RAW POWER in the AVM2 virtual machine that runs flash9/as3, cryptography, like compression, is very processor intensive and needs a fair amount of power to be worth the time (usually a balancing mechanism). I am working on a few security apps in AIR and Flash9 for a project and a product so this is the best of what I have found to share. I will be sure to post here when these projects are complete.
There are two that are pretty good as3 kits that have decent support for crypto and hashing, actually as3crypto is quite broad in their support or most common crypto algorithms, even hashing support up to SHA-256 and ciphers 3DES, AES, RC4.
This is not really a comparison just some kits that have tools you might need. as3crypto is definitely the way to go for more heavy ecryption with common ciphers, but if you are just hashing some text as3corelib might work for your project. as3corelib is a more broad toolkit that is made or sponsored by Adobe that has JSON, RSS, support and other tools. It is a great core lib, but not as deep in the encryption area. I am actually using both in the stuff I am working on, as3corelib for some other uses (JSON,RSS) and as3crypto for all encryption and hashing.
The two are:
- as3corelib
- Open source
- Support for hashing algorithms only.
- Browse source
- as3crypto
- Robust, broad encryption and security support
- Open source
- Demo
- Browse source
- Broad support of algorithms
-
-
TLS 1.0 support, exposed through TLSSocket and TLSEngine classes
-
X.509 Certificate support, including parsing, and validation
-
built-in list of common root Certificate Authorities
-
symmetric ciphers: AES, Blowfish, DES, 3DES, XTEA, RC4
-
confidentiality modes: CTR, CBC, CFB, CFB-8, OFB, ECB
-
public key crypto: RSA (encryption, decryption, signing, verifying and key generation)
-
padding: PKCS#1 (type 1 and 2), PKCS#5
-
BigInteger library
-
hashing function: SHA-256, SHA-224, SHA-1, MD5, MD2
-
HMAC support
-
prng: TLSPRF and stream-cypher-based PRNG.
-
minimal ASN-1/DER support for PEM key parsing and X-509 cert parsing
-
Crypto – Shortcut class to access many classes above.
-
Hex, Base64 – Static methods to convert binary data to and from text formats
-
-
As3 Crypto is a cryptography library written in Actionscript 3 that provides several common algorithms, as well as TLS 1.0 support. The library is offered under the BSD license, and include several derivative works from Java, C and javascript sources.
Here’s some numbers from as3Crypto home page that show the speed, note it has not been optimized just yet (since most of this is client side and only one user would be using it this is not an issue – server side is where this can have scale problems from parallel execution but flash is rarely server side if it is too slow, but it is quite fast)
The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes md2 1.01k 3.64k 15.08k 53.89k 171.76k md5 221.85k 447.32k 739.54k 893.72k 905.82k sha1 82.28k 184.78k 286.76k 336.03k 345.41k sha224 60.84k 125.67k 200.27k 234.28k 247.58k sha256 60.52k 126.30k 199.19k 234.04k 246.01k hmac-md5 48.37k 159.37k 282.87k 295.15k 341.21k hmac-sha1 18.29k 64.82k 165.72k 277.60k 342.52k hmac-sha224 5.75k 24.84k 125.71k 204.35k 256.36k hmac-sha256 15.10k 49.33k 123.71k 206.17k 249.08k rc4 117.24k 381.34k 878.93k 1315.01k 1539.44k xtea-cbc 2.49k 6.48k 12.80k 33.00k 44.48k aes128-cbc 1.61k 4.01k 22.97k 78.55k 205.01k aes192-cbc 1.34k 5.13k 20.91k 69.45k 172.43k aes256-cbc 1.48k 5.63k 18.87k 63.45k 150.39k blowfish-cbc 2.77k 10.81k 42.28k 140.27k 343.05k des-cbc 2.53k 9.73k 35.20k 124.84k 624.88k 3des-cbc 2.50k 9.72k 35.61k 115.21k 253.42kThe library has not been optimized for speed, and those numbers could probably be improved.
They both have minimal or none ASN.1 support which I will need but I can port much of this from my favorite Java/C# crypto kit from the legion of the bouncy castle of which I was happy to find was a substantial base for this kit.
Whatever you do don’t send any type of message from your crypto kits with aes 256 cipher and sha-256 hashing to Iran from the US.
Mike Chambers has a great post on parsing RSS in AS3 with as3syndicationlib. I had some info on this in development but Mike’s post is very simple and just posting the code here for reference.
import com.adobe.utils.XMLUtil; import com.adobe.xml.syndication.rss.Item20; import com.adobe.xml.syndication.rss.RSS20; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.SecurityErrorEvent; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLRequestMethod; private var loader:URLLoader; //url of rss 2.0 feed private static const RSS_URL:String = "http://feeds.feedburner.com/MikeChambers/"; //called when user presses the button to load feed private function onLoadPress():void { loader = new URLLoader(); //request pointing to feed var request:URLRequest = new URLRequest(RSS_URL); request.method = URLRequestMethod.GET; //listen for when the data loads loader.addEventListener(Event.COMPLETE, onDataLoad); //listen for error events loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError); loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); //load the feed data loader.load(request); } //called once the data has loaded from the feed private function onDataLoad(e:Event):void { //get the raw string data from the feed var rawRSS:String = URLLoader(e.target).data; //parse it as RSS parseRSS(rawRSS); } //parses RSS 2.0 feed and prints out the feed titles into //the text area private function parseRSS(data:String):void { //XMLSyndicationLibrary does not validate that the data contains valid //XML, so you need to validate that the data is valid XML. //We use the XMLUtil.isValidXML API from the corelib library. if(!XMLUtil.isValidXML(data)) { writeOutput("Feed does not contain valid XML."); return; } //create RSS20 instance var rss:RSS20 = new RSS20(); //parse the raw rss data rss.parse(data); //get all of the items within the feed var items:Array = rss.items; //loop through each item in the feed for each(var item:Item20 in items) { //print out the title of each item writeOutput(item.title); } } private function writeOutput(data:String):void { outputField.text += data + "\n"; } private function onIOError(e:IOErrorEvent):void { writeOutput("IOError : " + e.text); } private function onSecurityError(e:SecurityErrorEvent):void { writeOutput("SecurityError : " + e.text); }
Check out the full post on this at Mike’s blog.
Here is an interesting look to start the new year at Google Trends for some common keywords to this blog audience. Comparing AS2, AS3, Silverlight and actionscript you can see that there is some pretty interesting things happening.
| as3 | as2 | actionscript | silverlight |
First off, AS2 and AS3 are clouded because they are also related to EDI and EDI-INT so they get a bit inflated. Silverlight though is pretty unique in the naming. So from this graph we can see this happening:
- Silverlight and AS3 are growing rapidly
- Silverlight is crossing over as3 or meeting it
- The market looking for Silverlight is about 8-10 times as large as actionscript/as3/as3
- Silverlight and AS3 are growing, AS2 has no growth left and is an EOL language (end of life)
- AS2 (even with crossover to EDI trends for “as2″) leveled out, where AS3 is starting to lift to a larger market. This is strongly due to it being a fun language based on ES4 and interests programmers.
- The as3 effect started right in March-April 2007 (hrm I started this blog in April 2007 coincidenc? j/k
)
Another chart including Flex shows a better picture of the keyword wars between flex and silverlight.
| as3 | as2 | actionscript | silverlight | flex |
So from this graph we can see this happening:
- Flex has a large buzz
- Adobe’s marketing efforts are many while silverlight is more unique and focused
- Flex, as3 and Silverlight are popular, and growing in their support (the growth market for technology is in these areas, not in tech from Flash 8/as2)
- AS2 still taking a nosedive
Flash and Flex programmers and designers should know that with Silverlight 2.0 release coming and the capabilities of Silverlight 2.0 more competitive, flashers should be working on Flex, Flash9 or at least AS3 if not Flex. The RIA competition market will heat up immensely this year with Silverlight 2.0 and possibly Flex3 and coding and programming for Flash and Flex is becoming more involved. It also has a very strong competitor in Silverlight 2.0 coming that will drive this market.
This is all great news if you are ready for it, if you are still coding actionscript2 (AS2) and paying no mind to Silverlight, Flex or at least actionscript3 (AS3) then you will see your market slowly start to fade as things are ramped up and more of a programming focus in the vector wars. If you are a flash coder and ignoring Silverlight, your solutions will suffer. If you are a silverlight coder or .NET coder and ignoring the Flex and AS3 rise your solutions will suffer. I have been playing in AS3, Flex and Silverlight for over a year on both now and they are an entirely new platform with great programming models. The competition puts focus on this market so it is a great time to be skilled in these areas.
Using SharedObjects in Flash is very simple. Flash has SharedObjects that have been in the player since Flash6 when the introduction of Flash Communication Server which is now Flash Media Server which is releasing version 3 soon (also remote SharedObjects in Red5 is an open source RTMP media server that is based on Flash Media Server). So we can thank this release for SharedObjects, Camera objects, Audio, lots of the NetConnections, protocol enhancements and many other things. However to keep the tips simple we will just touch on the local usage and post a series of posts on these objects.
SharedObjects locally and remote have changed the way offline is thought about and are the backbone of many offline systems and prototypes. They have been influential in moving storage locally to remote in a lightweight AMF0 or AMF3 format.
SharedObject is in the flash.net namespace in AS3.
Here we show how to use the local version of a SharedObject to store data in the most simple form.
import flash.net.SharedObject; var so:SharedObject = SharedObject.getLocal("userData"); so.data.username= "user1377"; so.data.pwdhash= "[hash] or pwd"; so.flush(); // writes changes to disk
You can see this is extremely simple to store data.Here we show how to use the local version of a SharedObject to retrieve data in the most simple form.
import flash.net.SharedObject; var so:SharedObject = SharedObject.getLocal("userData"); var username:String = so.data.username; var pwdhash:String = so.data.pwdhash;
That is it! In the most basic form SharedObjects are more simple than cookies and also are quite nice living outside the bounds of the cookies folder. If a user deletes all cookies it will not delete the SharedObjects. To delete SharedObjects you need to roght click on the Flash player, go to Settings and delete the objects there.You can store any type of data Flash supports from objects to numbers to strings in the SharedObject data.
import flash.net.SharedObject; var so:SharedObject = SharedObject.getLocal("userData"); so.data.username= "user1377"; so.data.uid= new Number(1337); var obj:Object = new Object(); obj.prop = "value"; so.data.userobj= obj; so.flush(); // writes changes to disk
For large applications SharedObjects local are great because users can have their SharedObject space set to a high amount of space or unlmited for large offline type apps or more complex apps stored in a state object. It gets interesting when you pass this to the server in AMF or extremely compact AMF3 format to a remote stored object, via remoting, Shared Object events or any way you want to.We will be posting more on remote shared objects and some of the other tools such as Camera and Streams for AS3 over the coming weeks and deeper into the Sync Events for remote and local SOs.Sephiroth has a great Python tool to peer into the SOs on disk.
The first version of SharedObject Reader was written in python 2.2.
This new version is written in C# (C Sharp) as it’s now part of FlashDevelop editor.
Red5 also does this as well as many AMF kits.
Sync Events for SharedObject (as they change they launch a sync event)
Event object type: flash.events.SyncEvent
SyncEvent.type property = flash.events.SyncEvent.SYNC
Read more at adobe docs:
Sample from AS3 docs showing usage
package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.events.NetStatusEvent; import flash.net.SharedObject; import flash.net.SharedObjectFlushStatus; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; public class SharedObjectExample extends Sprite { private var mySo:SharedObject; public function SharedObjectExample() { buildUI(); saveBtn.addEventListener(MouseEvent.CLICK, saveValue); clearBtn.addEventListener(MouseEvent.CLICK, clearValue); mySo = SharedObject.getLocal("application-name"); output.appendText("SharedObject loaded...\n"); output.appendText("loaded value: " + mySo.data.savedValue + "\n\n"); } private function saveValue(event:MouseEvent):void { output.appendText("saving value...\n"); mySo.data.savedValue = input.text; var flushStatus:String = null; try { flushStatus = mySo.flush(10000); } catch (error:Error) { output.appendText("Error...Could not write SharedObject to disk\n"); } if (flushStatus != null) { switch (flushStatus) { case SharedObjectFlushStatus.PENDING: output.appendText("Requesting permission to save object...\n"); mySo.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus); break; case SharedObjectFlushStatus.FLUSHED: output.appendText("Value flushed to disk.\n"); break; } } output.appendText("\n"); } private function clearValue(event:MouseEvent):void { output.appendText("Cleared saved value...Reload SWF and the value should be \"undefined\".\n\n"); delete mySo.data.savedValue; } private function onFlushStatus(event:NetStatusEvent):void { output.appendText("User closed permission dialog...\n"); switch (event.info.code) { case "SharedObject.Flush.Success": output.appendText("User granted permission -- value saved.\n"); break; case "SharedObject.Flush.Failed": output.appendText("User denied permission -- value not saved.\n"); break; } output.appendText("\n"); mySo.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus); } // UI elements private var inputLbl:TextField; private var input:TextField; private var output:TextField; private var saveBtn:Sprite; private var clearBtn:Sprite; private function buildUI():void { // input label inputLbl = new TextField(); addChild(inputLbl); inputLbl.x = 10; inputLbl.y = 10; inputLbl.text = "Value to save:"; // input TextField input = new TextField(); addChild(input); input.x = 80; input.y = 10; input.width = 100; input.height = 20; input.border = true; input.background = true; input.type = TextFieldType.INPUT; // output TextField output = new TextField(); addChild(output); output.x = 10; output.y = 35; output.width = 250; output.height = 250; output.multiline = true; output.wordWrap = true; output.border = true; output.background = true; // Save button saveBtn = new Sprite(); addChild(saveBtn); saveBtn.x = 190; saveBtn.y = 10; saveBtn.useHandCursor = true; saveBtn.graphics.lineStyle(1); saveBtn.graphics.beginFill(0xcccccc); saveBtn.graphics.drawRoundRect(0, 0, 30, 20, 5, 5); var saveLbl:TextField = new TextField(); saveBtn.addChild(saveLbl); saveLbl.text = "Save"; saveLbl.selectable = false; // Clear button clearBtn = new Sprite(); addChild(clearBtn); clearBtn.x = 230; clearBtn.y = 10; clearBtn.useHandCursor = true; clearBtn.graphics.lineStyle(1); clearBtn.graphics.beginFill(0xcccccc); clearBtn.graphics.drawRoundRect(0, 0, 30, 20, 5, 5); var clearLbl:TextField = new TextField(); clearBtn.addChild(clearLbl); clearLbl.text = "Clear"; clearLbl.selectable = false; } } }

haXe, one of the coolest and most versatile languages and platforms of today just released something to add to the already amazing feature set of haXe. Nicolas Cannasse has posted about releasing haXe Video 1.0. I have been engulfed by Red5 for a few weeks and this could not have come at a better time for fun.
haxeVideo is an opensource video streaming server entirely written in haXe.
Features of haXe Video 1.0:
- FLV streaming using RTMP protocol
- Webcam and Microphone recording to FLV file
- Live streaming for web conferencing
- light and fast scalable server
- only 50 KB of server source code : modify whatever you need !
Links
- haXe video at google code
- Blog post on the release
- haXe video site
-
-
Latest News about haXe
-
Introduction to haXe
-
The haXe Language Reference
-
haXe Documentation
-
Download haXe files
-
Projects related to haXe
-
License of haXe
-
The haXe Community Blog
-




