private byte [] cipher(byte [] attribute, byte [] key, byte[] iv, int mode)
    {
        byte [] result = null;
        try
        {
            // Create AES encryption key
            Key aesKey = new SecretKeySpec(key, "AES");

            // Create AES Cipher
            Cipher aesCipher = Cipher.getInstance(ALGORITHM);

            // Initialize AES Cipher and convert
            aesCipher.init(mode, aesKey, new IvParameterSpec(iv));
            result = aesCipher.doFinal(attribute);
        }
        catch (Exception e)
        {
            log.error("AES cipher failed", e);
        }
        return result;
    }
Symmetric encrypt/decrypt routine.

@param attribute The value to be converted
@param key The encryption key
@param mode The cipher mode (encrypt or decrypt)
@return The converted attribute, or null if conversion fails
xmppserver/src/main/java/org/jivesoftware/util/AesEncryptor.java