To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Display Modes
Old 11-17-2005, 07:36 AM   #1
wombatLove
Registered Deviant
 
Join Date: Sep 2004
Location: Cornelius, OR, USA
Posts: 280
MD5 Hash Values

If anyone is interested in calculating MD5 hash values in their Flash files, I've thrown together some code in an ActionScript class for everyone to enjoy. Useful for calculating file checksums, password authentication and so forth.

From the .AS file:
Code:
/* -----------------------------
MD5Hash.as

Creates a class called Hash.MD5Hash used to calculate the MD5 hash value of a given set of data.
Place this file in a subdirectory named Hash in your classpath for ActionScript.

Use 'import Hash.MD5Hash;' to include the .as file
Use 'm = new MD5Hash("a");' to initialize a new instance

Class exports the following functions
// Constructor, takes one string
	MD5Hash(s:String)

// Getter/Setter functions
	getText():String -- returns string passed to the constructor or setText() function
	setText( s:String ):Void -- sets the internal data set to a new value and re-calculates the hash
	getHash():String -- returns the last calculated hash value
	toString():String -- synonym for getHash()
	valueOf():String -- synonym for getHash()

To re-use an existing Hash instance, simply call the setText() function with a new dataset, the hash
value will be re-calculated instantly.

Example:
////// BEGIN EXAMPLE //////
import Hash.MD5Hash;

m = new MD5Hash();
trace( m.getText() + ": " + m.getHash() );
// should return 'd41d8cd98f00b204e9800998ecf8427e'

m.setText("");  // an undefined value is the same as an empty string, should get the same result
trace( m.getText() + ": " + m.getHash() );
// should also return 'd41d8cd98f00b204e9800998ecf8427e'

m.setText("a");
trace( m.getText() + ": " + m.getHash() );
// should return '0cc175b9c0f1b6a831c399e269772661'

m.setText( "The quick brown fox jumps over the lazy dog; what a boring and useless phrase" );
trace( m.getText() + ": " + m.getHash() );
// should return 'f35cbee66b5f212043f5d6a12472ed6c'
//////  END EXAMPLE  //////

Portions of this code were borrowed from http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html
*/
Enjoy!
Attached Files
File Type: zip MD5Hash.zip (3.8 KB, 611 views)
wombatLove is offline   Reply With Quote
Old 09-26-2009, 05:05 AM   #2
Marraboy
Member
 
Join Date: Jan 2004
Location: Carlisle, UK
Posts: 94
Thumbs up

I know this is an old thread, but thanks anyway!

JT
__________________
It is confirmed that I am quite sad. I told the wife I was 'loading' the pizza into the oven!
Marraboy is offline   Reply With Quote
Old 02-11-2010, 05:37 AM   #3
davitz38
Junior Member
 
Join Date: Feb 2010
Posts: 2
Hey,
Well, this is an old post, but some of you going thru this thread and looking for a tool to hash a string, try this online md5 converter
David
davitz38 is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:23 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.