Infatti in quella classe non uso Java, ma sfrutto i comandi sql. Tuttavia quella classe per ogni crittografia effettuata richiama un comando sql 
Questa è la classe che ho implementato per crittografare usando Java
codice:
package beans;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class SecurityUtils implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2525681816498748588L;
private String seme;
private SecretKey key;
private String messaggio;
public String getSeme(){
return seme;
}
public void setSeme(String seme){
this.seme=seme;
}
public String getMessaggio(){
return messaggio;
}
public void setMessaggio(String messaggio){
this.messaggio=messaggio;
}
/**
* Genera una chiave a partire da un seme inziale, restituendo sempre la stessa chiave.
*/
public void genKey() throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException {
DESKeySpec des=new DESKeySpec(seme.getBytes());
SecretKeyFactory secret=SecretKeyFactory.getInstance("DES");
key= secret.generateSecret(des);
}
/**
* Decripta una stringa a partire da una chiave privata Key
* @param key
* @param mess
* @return
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
* @throws InvalidKeyException
* @throws IOException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
* @throws InvalidKeySpecException
*/
public String getDecrypt() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IOException, IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException {
genKey();
Cipher cipher=Cipher.getInstance("DES");
cipher.init(Cipher.DECRYPT_MODE,key);
BASE64Decoder decoder = new BASE64Decoder();
byte[] raw = decoder.decodeBuffer(messaggio);
byte[] stringBytes = cipher.doFinal(raw);
return new String(stringBytes,"UTF8");
}
/**
* Cripta una stringa usando una chiave privata Key
* @param key
* @param mess
* @return
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
* @throws UnsupportedEncodingException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
* @throws InvalidKeySpecException
*/
public String getCrypt() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException{
genKey();
Cipher cipher=Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] stringBytes=messaggio.getBytes("UTF8");
byte[] raw=cipher.doFinal(stringBytes);
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(raw);
}
}