Assuming that you don't want to use the crypto extensions, then take a look at the AES.java file at this project https://code.google.com/p/jomnilink/