Flex Encryption (MD5, SHA1, SHA224, SHA256, HMAC)
Line Break
Author: Janez Feldin (6 Articles) - Author Website
Janez likes to experiment with flash in his own free time. His other hobbies are playing volleyball, listening to the music, watching movies and above all else, paragliding.
After a question on our flex forum about MD5 encryption, I decided to write an example about all the encryption types available in Flex.
Encryption is not available by default, you have to download the latest version of the (open source) project AS3corelib.
If you would like to encrypt a String with an MD5, you have the MD5 class in as3corelib-.92.1srccomadobecryptoMD5.as.
Import this class and than just call
1 | MD5.hash("some string"); |
and there you go…
To show you every encryption method I’ve written this example.
Janez
No related posts.
Comments
6 Responses to “Flex Encryption (MD5, SHA1, SHA224, SHA256, HMAC)”



(
thanks pal for this example!
i just tried to check how mysql is encrypting its passwords
SELECT PASSWORD(‘asdfjkl123!’); -> *3CE6C81118685E32AA2EC54A61DDA51CC4B9AA94
but none of the functions above seem to match that.
do you know why?
best regards!
If none of the above methods match than its most likely that mysql uses some other encryption method.
I think you could find your answer if you go in mysql documentation and search what method mysql uses and than try to find the right class for flex to encrypt with the same method
how do you use the as3corelib to generate md5s of a file??
need to get a local file and generate an md5 – please there are no tuts on the net for this subject
thanks
If you want to encode something with md5 you will need to have a string, so to represent a file with a string simply load it with URLLoader:
Here is the code to acctualy load the file:
2
3
loader.addEventListener(Event.COMPLETE, fileLoaded);
loader.load(new URLRequest("path_to_your_file"));
and the function that gets called when your file is fully loaded:
2
3
4
5
{
var file_string:String = e.target.data;
//so this "file_string" is now the string you want to encode with md5
}
Hope this helps…
Regards
The title is confusing. MD5 is not an encryption method, but a Hash.
Actually only HMAC is an encryption (I think), all others are Hash