Code example for DESKeySpec

0
			throw new EntityException(e);
		} 
	} 
	 
	private Cipher createCipher(boolean isEncrypt) throws Exception{
		DESKeySpec desKeySpec = new DESKeySpec(key.getBytes(encoding));
		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
		SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
		IvParameterSpec ips = new IvParameterSpec(iv.getBytes(encoding));
		Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); 
        cipher.init(isEncrypt?Cipher.ENCRYPT_MODE:Cipher.DECRYPT_MODE, secretKey, ips);  
        return cipher;
	} 
	 
 
	public static void main(String[] args) {
		DES des=new DES();
		String e=des.encrypt("jxvaframework");
		System.out.println(e);
		System.out.println(des.decrypt(e));