byte[] encryptPayload(String payload,byte[] contentEncryptionKey,byte[] initializationVector) throws EncryptDataException {
  try {
    SecretKeySpec secretKey=new SecretKeySpec(contentEncryptionKey,AES_ALGORITHM_TYPE);
    IvParameterSpec ivParameter=new IvParameterSpec(initializationVector);
    Cipher aesCipher=Cipher.getInstance(AES_ALGORITHM_MODE);
    aesCipher.init(Cipher.ENCRYPT_MODE,secretKey,ivParameter);
    byte[] encryptedData=aesCipher.doFinal(payload.getBytes());
    return encryptedData;
  }
 catch (  Exception e) {
    throw new EncryptDataException("Error while encrypting data ",e);
  }
}

byte [ ] encryptPayload ( String payload , byte [ ] contentEncryptionKey , byte [ ] initializationVector ) throws EncryptDataException { try { SecretKeySpec secretKey = new SecretKeySpec ( contentEncryptionKey , AES_ALGORITHM_TYPE ) ; IvParameterSpec ivParameter = new IvParameterSpec ( initializationVector ) ; Cipher aesCipher = Cipher . getInstance ( AES_ALGORITHM_MODE ) ; aesCipher . init ( Cipher . ENCRYPT_MODE , secretKey , ivParameter ) ; byte [ ] encryptedData = aesCipher . doFinal ( payload . getBytes ( ) ) ; return encryptedData ; } catch ( Exception e ) { throw new EncryptDataException ( "Error while encrypting data " , e ) ; } }
encrypts a given string with a contentencryptionkey and initializationvector using aes
