code: public String encryptPassword(String userPassword) throws NoSuchAlgorithmException, InvalidKeySpecException {
          char[] chars = userPassword.toCharArray();
          byte[] salt = getSalt();
  
          PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength);
          SecretKeyFactory skf = SecretKeyFactory.getInstance(keyAlgorythm);
          byte[] hash = skf.generateSecret(spec).getEncoded();
          return toHex((iterations + ":" + toHex(salt) + ":" + toHex(hash)).getBytes());
      }
docs: /*
  @param userPassword The password to be encrypted.
  @return The encrypted string digest.
  @throws NoSuchAlgorithmException encryption exceptions.
  @throws InvalidKeySpecException encryption exceptions.