Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

crypt(3) $6$ password hash algorithm (based on SHA-512) in Java?

I'm looking for a Java function to generate/verify password hashes that were encoded in the way crypt(3) does when storing them in the Linux "/etc/shadow" file if sha512 is activated in "/etc/pam.d/common-password".

The plaintext string "geheim" will translate to:

"$6$WoC532HB$LagBJ00vAGNGu8p9oeYDOSNZo9vTNTzOgPA.K0bJoiXfbcpj3jBuTkNwdzCrSNadRi8LanH1tH6tGGPPp/Lp3."

From http://www.akkadia.org/drepper/SHA-crypt.txt I understand that, like with MD5, it's not just a SHA hash like DigestUtils or the Java MessageDigest classes produce but an algorithm that does a bit more magic.

like image 370
lathspell42 Avatar asked Jan 30 '12 10:01

lathspell42


2 Answers

I found Java implementations for all the new crypt() algorithms here: ftp://ftp.arlut.utexas.edu/java_hashes/

like image 186
lathspell42 Avatar answered Sep 20 '22 11:09

lathspell42


Take a look on Apache Commons Codec Digest

Also jBCrypt you may find useful.

In this article Modular Crypt Format or, a side note about a standard that isn’t a lot of details of Crypt3 format.

like image 35
Sergey Ponomarev Avatar answered Sep 21 '22 11:09

Sergey Ponomarev