question: public byte [ ] encrypt ( FacesContext facesContext , byte [ ] bytes ) { byte [ ] securedata = null ; try { SecureRandom rand = new SecureRandom ( ) ; byte [ ] iv = new byte [ 16 ] ; rand . nextBytes ( iv ) ; IvParameterSpec ivspec = new IvParameterSpec ( iv ) ; Cipher encryptCipher = Cipher . getInstance ( CIPHER_CODE ) ; SecretKey secKey = getSecretKey ( facesContext ) ; encryptCipher . init ( Cipher . ENCRYPT_MODE , secKey , ivspec ) ; Mac encryptMac = Mac . getInstance ( MAC_CODE ) ; encryptMac . init ( secKey ) ; encryptMac . update ( iv ) ; byte [ ] encdata = encryptCipher . doFinal ( bytes ) ; byte [ ] macBytes = encryptMac . doFinal ( encdata ) ; byte [ ] tmp = concatBytes ( macBytes , iv ) ; securedata = concatBytes ( tmp , encdata ) ; } catch ( NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalStateException | IllegalBlockSizeException | BadPaddingException e ) { if ( LOGGER . isLoggable ( Level . SEVERE ) ) { LOGGER . log ( Level . SEVERE , "Unexpected exception initializing encryption." + "  No encryption will be performed." , e ) ; } return null ; } return securedata ; }
target:  This method: Encrypts bytes using a cipher.   Generates MAC for intialization vector of the cipher Generates MAC for encrypted data Returns a byte array consisting of the following concatenated together: |MAC for cnrypted Data | MAC for Init Vector | Encrypted Data |