Wednesday, December 2, 2009

as3corelib Contains Crypto Utils for FLEX MD5 Hash

I needed to store MD5 hashed passwords in the database and was delighted to find the as3corelib already contains the necessary libraries.  While there are many more features, I only needed the MD5 Hash function so I only copied in the com.adobe.crypto.MD5 and com.adobe.utils.* files.  With the .as files added to my Flex project, hashing the password was a simple as calling:

    MD5.hash( passwordComp.getPassword() );

 

I verified that it returns the same hash as the MySQL MD5 function

UPDATE user_table SET password = MD5(‘change_me’) WHERE username = ‘sandman’