Java Encryption

Encrytion Example
/* * Created on 05-Apr-2006 * * $Id: $ * @author pkane */ package edu. london. ad ; import java. math. BigInteger ; import javax. crypto. Cipher ; import javax. crypto. SecretKey ; import javax. crypto. SecretKeyFactory ; import javax. crypto. spec. DESKeySpec ; public class PasswordMaker { private static byte [] desKeyData = "95179873" .getBytes; private static byte [] encrypt( byte [] inpBytes, SecretKey key, String xform) throws Exception {   Cipher cipher = Cipher.getInstance( xform ); cipher.init( Cipher.ENCRYPT_MODE, key ); return cipher.doFinal( inpBytes ); } private static byte [] decrypt( byte [] inpBytes, SecretKey key, String xform) throws Exception {   Cipher cipher = Cipher.getInstance( xform ); cipher.init( Cipher.DECRYPT_MODE, key ); return cipher.doFinal( inpBytes ); } public static void main( String [] unused) throws Exception {   String xform = "DES/ECB/PKCS5Padding" ; // Generate a secret key DESKeySpec desKeySpec = new DESKeySpec( desKeyData ); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance( "DES" ); SecretKey secretKey = keyFactory.generateSecret( desKeySpec ); String passwordToEncrypt = "myPassword" ; byte [] dataBytes = passwordToEncrypt.getBytes; byte [] encBytes = encrypt( dataBytes, secretKey, xform ); BigInteger bi = new BigInteger ( encBytes ); byte [] decBytes = decrypt( encBytes, secretKey, xform ); boolean expected = java.util.Arrays.equals( dataBytes, decBytes ); System .out.println( "Password encrypted is [" + bi.toString( 36 ) + "]" ); System .out.println( "Encryption check " + (expected ? "SUCCEEDED!" : "FAILED!" ) );   String confirmEncryptionWord = "5kb1n582fpp9hple6nvn51jzg" ; BigInteger bigInteger = new BigInteger ( confirmEncryptionWord, 36 ); byte [] word = bigInteger.toByteArray; byte [] decrypt = decrypt( word, secretKey, xform ); System .out.println( "decrypted [" + new String ( decrypt ) + "]" ); } }