Equivalent of PHP's crypt function in actionscript
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: Her开发者_运维技巧e 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):
temjCCsjBECmUas3crypto 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
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:
- http://en.wikipedia.org/wiki/Cryptographic_hash_function
- http://en.wikipedia.org/wiki/Crypt_(Unix)
- http://en.wikipedia.org/wiki/Salt_(cryptography)
精彩评论