code: public static byte[] pbkdf2(String alg, byte[] P, byte[] S, int c, int dkLen) throws GeneralSecurityException {
          Mac mac = Mac.getInstance(alg);
          mac.init(new SecretKeySpec(P, alg));
          byte[] DK = new byte[dkLen];
          pbkdf2(mac, S, c, DK, dkLen);
          return DK;
      }
docs: Implementation of PBKDF2 (RFC2898).
  
  @param   alg     HMAC algorithm to use.
  @param   P       Password.
  @param   S       Salt.
  @param   c       Iteration count.
  @param   dkLen   Intended length, in octets, of the derived key.
  
  @return  The derived key.
  
  @throws  GeneralSecurityException