code: public static byte[] encryptPasswordBased(final String algorithm, final byte[] data, final char[] password, final byte[] salt,
              final int count) {
  
          checkNotNull("algorithm", algorithm);
          checkNotNull("data", data);
          checkNotNull("password", password);
          checkNotNull("salt", salt);
  
          try {
              final Cipher cipher = createCipher(algorithm, Cipher.ENCRYPT_MODE, password, salt, count);
              return cipher.doFinal(data);
          } catch (final Exception ex) {
              throw new RuntimeException("Error encrypting the password!", ex);
          }
      }
docs: Encrypts some data based on a password.
  
  @param algorithm
  PBE algorithm like "PBEWithMD5AndDES" or "PBEWithMD5AndTripleDES" - Cannot be <code>null</code>.
  @param data
  Data to encrypt - Cannot be <code>null</code>.
  @param password
  Password - Cannot be <code>null</code>.
  @param salt
  Salt usable with algorithm - Cannot be <code>null</code>.
  @param count
  Iterations.
  
  @return Encrypted data.