views:

65

answers:

4

Hello,

Could someone point me in the direction of a crypt(3) library for java? One that generates results similar to PHP. e.g.

james => $1$uAjE75CY$XVIp.DpCuwQTG60h.r5er/

Thanks

Update:

The password above is separated by $. The 1 represents MD5 (variation). The next token represents the salt used for the hash and the last token represents the MD5 hash. This hash is a variation from MD5 algorithm.

+1  A: 

here is one

Peter Recore
A: 

"java crypt" gives several candidates at Google.

Thorbjørn Ravn Andersen
yes, found all those but they are not generating passwords similar to that of php crypt().
James Moore
@James Is it a requirement that the generated passwords (Java, PHP) are the same?
extraneon
yes it is. I have updated the question.
James Moore
You are aware that most crypt-implementation needs a salt?
Thorbjørn Ravn Andersen
+1  A: 

The crypt variant you are looking for is an MD5 hash (identified by the $1$ prefix). The method for doing this has been answered here already. Then you add the 1$1 prefix after hashing and remove it before comparing it with a candidate hash.

bjg
A: 

Try this one,

http://www.java2s.com/Open-Source/Java-Document/Groupware/LibreSource/md5/MD5Crypt.java.htm

I was able to use it to compare password generated by PHP crypt.

Please notice that this class uses its own MD5 class.

ZZ Coder
Well found. Thanks.
James Moore