Package org.eclipse.jetty.util.security
Class UnixCrypt
- java.lang.Object
-
- org.eclipse.jetty.util.security.UnixCrypt
-
public class UnixCrypt extends java.lang.Object
Unix Crypt. Implements the one way cryptography used by Unix systems for simple password protection.- Version:
- $Id: UnixCrypt.java,v 1.1 2005/10/05 14:09:14 janb Exp $
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
A64TOI
private static long[][]
CF6464
private static byte[]
CIFP
private static byte[]
ExpandTr
private static long[][]
IE3264
private static byte[]
IP
private static byte[]
ITOA64
private static byte[]
P32Tr
private static byte[]
PC1
private static long[][]
PC1ROT
private static byte[]
PC2
private static long[][][]
PC2ROT
private static byte[]
Rotates
private static byte[][]
S
private static long[][]
SPE
-
Constructor Summary
Constructors Modifier Constructor Description private
UnixCrypt()
You can't call the constructer.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
crypt(java.lang.String key, java.lang.String setting)
Encrypts String into crypt (Unix) code.private static long
des_cipher(long in, int salt, int num_iter, long[] KS)
Returns the DES encrypted code of the given word with the specified environment.private static long[]
des_setkey(long keyword)
Returns the key schedule for the given key.private static void
init_perm(long[][] perm, byte[] p, int chars_out)
Initializes the given permutation table with the mapping table.static void
main(java.lang.String[] arg)
private static long
perm3264(int c, long[][] p)
Returns the permutation of the given 32-bit code with the specified permutataion table.private static long
perm6464(long c, long[][] p)
Returns the permutation of the given 64-bit code with the specified permutataion table.private static int
to_six_bit(int num)
Returns the transposed and split code of a 24-bit code into a 4-byte code, each having 6 bits.private static long
to_six_bit(long num)
Returns the transposed and split code of two 24-bit code into two 4-byte code, each having 6 bits.
-
-
-
Field Detail
-
IP
private static final byte[] IP
-
ExpandTr
private static final byte[] ExpandTr
-
PC1
private static final byte[] PC1
-
Rotates
private static final byte[] Rotates
-
PC2
private static final byte[] PC2
-
S
private static final byte[][] S
-
P32Tr
private static final byte[] P32Tr
-
CIFP
private static final byte[] CIFP
-
ITOA64
private static final byte[] ITOA64
-
A64TOI
private static final byte[] A64TOI
-
PC1ROT
private static final long[][] PC1ROT
-
PC2ROT
private static final long[][][] PC2ROT
-
IE3264
private static final long[][] IE3264
-
SPE
private static final long[][] SPE
-
CF6464
private static final long[][] CF6464
-
-
Method Detail
-
to_six_bit
private static int to_six_bit(int num)
Returns the transposed and split code of a 24-bit code into a 4-byte code, each having 6 bits.
-
to_six_bit
private static long to_six_bit(long num)
Returns the transposed and split code of two 24-bit code into two 4-byte code, each having 6 bits.
-
perm6464
private static long perm6464(long c, long[][] p)
Returns the permutation of the given 64-bit code with the specified permutataion table.
-
perm3264
private static long perm3264(int c, long[][] p)
Returns the permutation of the given 32-bit code with the specified permutataion table.
-
des_setkey
private static long[] des_setkey(long keyword)
Returns the key schedule for the given key.
-
des_cipher
private static long des_cipher(long in, int salt, int num_iter, long[] KS)
Returns the DES encrypted code of the given word with the specified environment.
-
init_perm
private static void init_perm(long[][] perm, byte[] p, int chars_out)
Initializes the given permutation table with the mapping table.
-
crypt
public static java.lang.String crypt(java.lang.String key, java.lang.String setting)
Encrypts String into crypt (Unix) code.- Parameters:
key
- the key to be encryptedsetting
- the salt to be used- Returns:
- the encrypted String
-
main
public static void main(java.lang.String[] arg)
-
-