A few days ago, I had to interoperate a Java application with an authentification database. The credentials were standard except the algorithm used to hash the password : crypt_md5. My colleage explained me that the crypt_md5 function was found in the GNU libc and used by the PAM module that fills the database.

As I know that Java doesn't support out-of-the-box this algorithm, my colleage suggests me to download the source code of the GNU libc and to port the code to Java. But before doing this, I made a quick research on Google and found that some project has already ported the code. But I didn't like the code I found, primarily because, it used the java.util.Random class.

So I decided to wrote my own port. 15 minutes later, it was done. But my test case still fails. The difference between the result and the expected result was just a matter of some character. 15 minutes later, I banged my head against my desk for not seeing a stupid sign error. If anybody cares, the source code is available for download. License included.