public class DESFactory {
public DESFactory(byte encKey[], byte desKey[]) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = encKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
enCipher = Cipher.getInstance("DES");
enCipher.init(1, key, sr);
rawKeyData = desKey;
dks = new DESKeySpec(rawKeyData);
key = keyFactory.generateSecret(dks);
deCipher = Cipher.getInstance("DES");
deCipher.init(2, key, sr);
}