com.openexchange.admin.tools
Class UnixCrypt
java.lang.Object
com.openexchange.admin.tools.UnixCrypt
public class UnixCrypt
- extends Object
Method Summary |
static String |
crypt(String original)
Encrypt a password given the cleartext password. |
static String |
crypt(String salt,
String original)
Encrypt a password given the cleartext password and a "salt". |
static boolean |
matches(String encryptedPassword,
String enteredPassword)
Check that enteredPassword encrypts to
encryptedPassword. |
encoding
public static String encoding
UnixCrypt
public UnixCrypt()
crypt
public static final String crypt(String salt,
String original)
throws UnsupportedEncodingException
Encrypt a password given the cleartext password and a "salt".
- Parameters:
salt
- A two-character string representing the salt used to
iterate the encryption engine in lots of different ways. If you
are generating a new encryption then this value should be
randomised.original
- The password to be encrypted.
- Returns:
- A string consisting of the 2-character salt followed by the
encrypted password.
- Throws:
UnsupportedEncodingException
crypt
public static final String crypt(String original)
throws UnsupportedEncodingException
Encrypt a password given the cleartext password. This method
generates a random salt using the 'java.util.Random' class.
- Parameters:
original
- The password to be encrypted.
- Returns:
- A string consisting of the 2-character salt followed by the
encrypted password.
- Throws:
UnsupportedEncodingException
matches
public static final boolean matches(String encryptedPassword,
String enteredPassword)
throws UnsupportedEncodingException
Check that enteredPassword encrypts to
encryptedPassword.
- Parameters:
encryptedPassword
- The encryptedPassword. The first
two characters are assumed to be the salt. This string would
be the same as one found in a Unix /etc/passwd file.enteredPassword
- The password as entered by the user (or
otherwise aquired).
- Returns:
- true if the password should be considered correct.
- Throws:
UnsupportedEncodingException