public String encrypt(String value){
  String securedata=null;
  byte[] bytes=value.getBytes(utf8);
  try {
    Cipher encryptCipher=Cipher.getInstance(CIPHER_CODE);
    encryptCipher.init(Cipher.ENCRYPT_MODE,sk,ivspec);
    byte[] encdata=encryptCipher.doFinal(bytes);
    securedata=DatatypeConverter.printBase64Binary(encdata);
  }
 catch (  NoSuchAlgorithmException|NoSuchPaddingException|InvalidKeyException|InvalidAlgorithmParameterException|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;
}

public String encrypt ( String value ) { String securedata = null ; byte [ ] bytes = value . getBytes ( utf8 ) ; try { Cipher encryptCipher = Cipher . getInstance ( CIPHER_CODE ) ; encryptCipher . init ( Cipher . ENCRYPT_MODE , sk , ivspec ) ; byte [ ] encdata = encryptCipher . doFinal ( bytes ) ; securedata = DatatypeConverter . printBase64Binary ( encdata ) ; } catch ( NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | 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 ; }
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 |
