jas2.jds.security
Class UnixCrypt
- java.lang.Object
-
- jas2.jds.security.UnixCrypt
-
public class UnixCrypt extends java.lang.ObjectThis class provides us with the ability to encrypt passwords when sent over the network streamContains static methods to encrypt and compare passwords with Unix encrypted passwords.
See John Dumas's Java Crypt page for the original source.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.Stringcrypt(java.lang.String original)Encrypt a password given the cleartext password.static java.lang.Stringcrypt(java.lang.String salt, java.lang.String original)Encrypt a password given the cleartext password and a "salt".static booleanmatches(java.lang.String encryptedPassword, java.lang.String enteredPassword)Check that enteredPassword encrypts to encryptedPassword.
-
-
-
Method Detail
-
crypt
public static final java.lang.String crypt(java.lang.String salt, java.lang.String original)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.
-
crypt
public static final java.lang.String crypt(java.lang.String original)
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.
-
matches
public static final boolean matches(java.lang.String encryptedPassword, java.lang.String enteredPassword)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.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG