Package org.apache.commons.codec.digest
Class UnixCrypt
- java.lang.Object
 - 
- org.apache.commons.codec.digest.UnixCrypt
 
 
- 
public class UnixCrypt extends java.lang.ObjectUNIX crypt(3) algorithm implementation.This class only implements the traditional 56 bit DES based algorithm. Please use DigestUtils.crypt() for a method that distinguishes between all the algorithms supported in the current glibc's crypt().
The Java implementation was taken from the JetSpeed Portal project (see org.apache.jetspeed.services.security.ldap.UnixCrypt).
This class is slightly incompatible if the given salt contains characters that are not part of the allowed range [a-zA-Z0-9./].
This class is immutable and thread-safe.
- Since:
 - 1.7
 
 
- 
- 
Constructor Summary
Constructors Constructor Description UnixCrypt()Deprecated.TODO Make private in 2.0. 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringcrypt(byte[] original)Generates a crypt(3) compatible hash using the DES algorithm.static java.lang.Stringcrypt(byte[] original, java.lang.String salt)Generates a crypt(3) compatible hash using the DES algorithm.static java.lang.Stringcrypt(java.lang.String original)Generates a crypt(3) compatible hash using the DES algorithm.static java.lang.Stringcrypt(java.lang.String original, java.lang.String salt)Generates a crypt(3) compatible hash using the DES algorithm. 
 - 
 
- 
- 
Method Detail
- 
crypt
public static java.lang.String crypt(byte[] original)
Generates a crypt(3) compatible hash using the DES algorithm.A salt is generated for you using
SecureRandom.- Parameters:
 original- plaintext password- Returns:
 - a 13 character string starting with the salt string
 
 
- 
crypt
public static java.lang.String crypt(byte[] original, java.lang.String salt)Generates a crypt(3) compatible hash using the DES algorithm.Using unspecified characters as salt results incompatible hash values.
- Parameters:
 original- plaintext passwordsalt- a two character string drawn from [a-zA-Z0-9./]. The salt may be null, in which case a salt is generated for you usingSecureRandom.- Returns:
 - a 13 character string starting with the salt string
 - Throws:
 java.lang.IllegalArgumentException- if the salt does not match the allowed pattern
 
- 
crypt
public static java.lang.String crypt(java.lang.String original)
Generates a crypt(3) compatible hash using the DES algorithm.A salt is generated for you using
SecureRandom.- Parameters:
 original- plaintext password- Returns:
 - a 13 character string starting with the salt string
 
 
- 
crypt
public static java.lang.String crypt(java.lang.String original, java.lang.String salt)Generates a crypt(3) compatible hash using the DES algorithm.- Parameters:
 original- plaintext passwordsalt- a two character string drawn from [a-zA-Z0-9./]. The salt may be null, in which case a salt is generated for you usingSecureRandom.- Returns:
 - a 13 character string starting with the salt string
 - Throws:
 java.lang.IllegalArgumentException- if the salt does not match the allowed pattern
 
 - 
 
 -