//richinternet.blog

Viewing By Entry / Main
Tuesday, October 12, 2004
SHA1 ActionScript 2.0 class

If you want data integrity you usually use message digest algorithms like MD5 or SHA1. Flex does not provide built-in message digest functionality so I throw this one in: an ActionScript 2.0 implementation of the Secure Hash Algorithm SHA1 based on the JavaScript implementation by Paul Johnston distributed under the BSD License. Basically, I just wrapped the functionality into static methods and added implicit getters/setters for property access (btw, the class also works in plain Flash MX 2004 projects). Usage is quite straightforward: just add the class package to the [flexcontext]/WEB-INF/flex/user_classes directory and you're set.

The most useful methods are

  • static de.richinternet.crypto.SHA1.encode(message:String):String - returns a 40 byte hexadecimal message digest (lower case hex chars by default)
  • static de.richinternet.crypto.SHA1.test(Void):Boolean - return true if the VM (i.e. the Flash Player) works ok

To change the default setting for the output format of the hexadecimal message digest use

  • static de.richinternet.crypto.SHA1.upperCaseHex:Boolean - set to true to force upper case output, default is false

There are some additional methods and properties (e.g. base64 output) which I'll document if time permits. Otherwise: Just check the source code for further information :)

Download class package: SHA1-v1.0.zip
Download sample MXML file: digest.zip

Dirk.

Comments

You could have saved yourself some time and use the SHA-1 ( or MD5 / TEA / AES / RSA / ROT13 ) classes from http://www.meychi.com/archive/000021.php :)


Hi there,

Thanks for the great code! I just thought I'd let you know that it doesn't work when compiled with MTASC, although it's quite an easy fix. More information about the solution here :

http://www.sebleedelisle.com/?p=91

thanks again!

Seb




Sun Mon Tue Wed Thu Fri Sat
   1234
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30   

About this blog
www.richinternet.de

AIR (9)
Apollo (3)
BlazeDS (8)
Breeze (1)
Central (5)
ColdFusion (54)
Flash (57)
Flash Media Server (6)
Flex (160)
Flex Trace Panel (6)
FXUG (3)
J2Flex (4)
MAX (31)
Mobile (1)
mxmlc (1)
Other topics (42)
Plugins (5)
Video (4)

Copy Fully Qualified Classname Plugin for Flash Builder 4 (CFQCN)

Recent Flex Technotes
Recent ColdFusion Technotes
Recent Flash Technotes

http://www.flexperten.de
http://www.flexforum.de
http://www.flex.org
http://www.bloginblack.de
http://www.cflex.net
flexcoders mailing-list
flexcoders archive
more links...

Aggregated by fullasagoog.com
Aggregated by MXNA

Short Mode | Full Mode

Herrlich & Ramuschkat