views:

56

answers:

2

I am migrating my PHP code to Google App Engine - Java.
Since I couldn't find an equivalent function of crypt in Java,
I can do without it if I find an equivalent function in actionscript.

Edit 1: Here is my php code for encrypting passwords :

$password = "test123";
$pwd = crypt($password,$password);
echo $pwd;

Output is (On Windows as well as a linux based server on HostMonser):
temjCCsjBECmU

A: 

Don't think you'll find an exact analog. crypt() as exists in PHP is an artifact of its Unix heritage, and is usually just a wrapper around the base C library. It won't even behave identically between operating systems.

What you should do is define your password hashing practice clearly (e.g. SHA256 with 8 bytes of salt or something), and run it through a library providing the appropriate algorithm.

Google for com.adobe.crypto (pretty sure it's part of the as3corelib project), it has several cryptographic hash functions.

You can accomplish this same thing in Java as well (and probably better and faster), though I don't know any particular libraries off the top of my head, not having dealt much with Java.

Incidentally, you should probably read through these articles before going much further:

Nicholas Knight
+2  A: 

as3crypto might be of help. It provides DES, and together with Base64, you should be able to recreate PHP's crypt function. OTOH, unless you really need the exact same behaviour, you might just as well take anything else the library offers.

greetz
back2dos

back2dos