anon.crypto
Class DESCrypt

java.lang.Object
  extended by anon.crypto.DESCrypt
All Implemented Interfaces:
ICrypt

public class DESCrypt
extends java.lang.Object
implements ICrypt

DESCrypt.java Java-based implementation of the unix crypt command Based upon C source code written by Eric Young, eay@psych.uq.oz.au from http://locutus.kingwoodcable.com/jfd/crypt.html


Field Summary
private static int[] con_salt
           
private static int[] cov_2char
           
private static int ITERATIONS
           
private static char[] saltChars
           
private static boolean[] shifts2
           
private static int[][] skb
           
private static int[][] SPtrans
           
 
Constructor Summary
DESCrypt()
           
 
Method Summary
private static int[] body(int[] schedule, int Eswap0, int Eswap1)
           
private static int byteToUnsigned(byte b)
           
 java.lang.String crypt(java.lang.String original)
          Encrypt a password given the cleartext password.
 java.lang.String crypt(java.lang.String original, java.lang.String salt)
          Creates a UNIX/BSD/Linux-compatible hash value from a password String and a salt value.
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)
           
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)
           
private static void PERM_OP(int a, int b, int n, int m, int[] results)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITERATIONS

private static final int ITERATIONS
See Also:
Constant Field Values

saltChars

private static final char[] saltChars

con_salt

private static final int[] con_salt

shifts2

private static final boolean[] shifts2

skb

private static final int[][] skb

SPtrans

private static final int[][] SPtrans

cov_2char

private static final int[] cov_2char
Constructor Detail

DESCrypt

public DESCrypt()
Method Detail

byteToUnsigned

private static final int byteToUnsigned(byte b)

fourBytesToInt

private static int fourBytesToInt(byte[] b,
                                  int offset)

intToFourBytes

private static final void intToFourBytes(int iValue,
                                         byte[] b,
                                         int offset)

PERM_OP

private static final void PERM_OP(int a,
                                  int b,
                                  int n,
                                  int m,
                                  int[] results)

HPERM_OP

private static final int HPERM_OP(int a,
                                  int n,
                                  int m)

des_set_key

private static int[] des_set_key(byte[] key)

D_ENCRYPT

private static final int D_ENCRYPT(int L,
                                   int R,
                                   int S,
                                   int E0,
                                   int E1,
                                   int[] s)

body

private static final int[] body(int[] schedule,
                                int Eswap0,
                                int Eswap1)

crypt

public 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.security.SecureRandom' class.

Specified by:
crypt in interface ICrypt
Parameters:
original - The password to be encrypted.
Returns:
A string consisting of the 2-character salt followed by the encrypted password.

See John Dumas's Java Crypt page for the original source.


crypt

public final java.lang.String crypt(java.lang.String original,
                                    java.lang.String salt)
Description copied from interface: ICrypt
Creates a UNIX/BSD/Linux-compatible hash value from a password String and a salt value. The maximum length of the salt may vary with the algorithm

Specified by:
crypt in interface ICrypt
Parameters:
original - a password as String
salt - a salt as String; the maximum length may vary
Returns:
a hash value for the password