|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.PingOO.DLAI.lib.util.PasswordCodec
Offers an implementation of the UNIX crypt command in Java.
Based upon C source code written by Eric Young
| Field Summary | |
private static int[] |
con_salt
|
private static int[] |
cov_2char
|
private static int |
ITERATIONS
The total number of iterations. |
private static boolean[] |
shifts2
|
private static int[][] |
skb
|
private static int[][] |
SPtrans
|
| Constructor Summary | |
private |
PasswordCodec()
Hides the constructor from the outside. |
| Method Summary | |
private static int[] |
body(int[] schedule,
int Eswap0,
int Eswap1)
|
private static int |
byteToUnsigned(byte b)
|
private static int |
D_ENCRYPT(int L,
int R,
int S,
int E0,
int E1,
int[] s)
|
private static int[] |
des_set_key(byte[] key)
|
static java.lang.String |
encode(java.lang.String original,
java.lang.String salt)
Ecrypts a string using the UNIX crypt algorithm. |
private static int |
fourBytesToInt(byte[] b,
int offset)
|
private static int |
HPERM_OP(int a,
int n,
int m)
|
private static void |
intToFourBytes(int iValue,
byte[] b,
int offset)
|
static void |
main(java.lang.String[] args)
Allows to run the crypt algorithm by itself. |
private static void |
PERM_OP(int a,
int b,
int n,
int m,
int[] results)
|
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static final int ITERATIONS
private static final int[] con_salt
private static final boolean[] shifts2
private static final int[][] skb
private static final int[][] SPtrans
private static final int[] cov_2char
| Constructor Detail |
private PasswordCodec()
| Method Detail |
private static final int byteToUnsigned(byte b)
b -
private static int fourBytesToInt(byte[] b,
int offset)
b - offset -
private static final void intToFourBytes(int iValue,
byte[] b,
int offset)
iValue - b - offset -
private static final void PERM_OP(int a,
int b,
int n,
int m,
int[] results)
a - b - n - m - results -
private static final int HPERM_OP(int a,
int n,
int m)
a - n - m - private static int[] des_set_key(byte[] key)
key -
private static final int D_ENCRYPT(int L,
int R,
int S,
int E0,
int E1,
int[] s)
L - R - S - EO - E1 - s -
private static final int[] body(int[] schedule,
int Eswap0,
int Eswap1)
schedule - Eswap0 - Eswap1 -
public static final java.lang.String encode(java.lang.String original,
java.lang.String salt)
throws java.lang.NullPointerException
char *crypt(const char *key, const char *salt);
key is a user's typed password.
salt is a two-character string chosen from the set [a-zA-Z0-9./]. This string is used to perturb the algorithm in one of 4096 different ways.
By taking the lowest 7 bit of each character of the key, a 56-bit key is obtained. This 56-bit key is used to encrypt repeatedly a constant string (usually a string consisting of all zeros). The returned value points to the encrypted password, a series of 13 printable ASCII characters (the first two characters represent the salt itself). The return value points to static data whose content is overwritten by each call.
Warning : The key space consists of 2**56 equal 7.2e16 possible values. Exhaustive searches of this key space are possible using massively parallel computers. Software, such as crack(1), is available which will search the portion of this key space that is generally used by humans for passwords. Hence, password selection should, at minimum, avoid common words and names. The use of a passwd(1) program that checks for crackable passwords during the selection process is recommended.
The DES algorithm itself has a few quirks which make the use of the crypt(3) interface a very poor choice for anything other than password authentication. If you are planning on using the crypt(3) interface for a cryptography project, don't do it : get a good book on encryption and one of the widely available DES libraries.
original - The string to crypt.salt - The 2 character array needed to crypt key.null.public static void main(java.lang.String[] args)
args -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||