code: def pbkdf2(password, salt, outlen, digesttype="sha1", iterations=2000):
      
      dgst = DigestType(digesttype)
      out = create_string_buffer(outlen)
      if isinstance(password,chartype):
          pwd = password.encode("utf-8")
      else:
          pwd = password
      res = libcrypto.PKCS5_PBKDF2_HMAC(pwd, len(pwd), salt, len(salt),
                                        iterations, dgst.digest, outlen, out)
      if res <= 0:
          raise LibCryptoError("error computing PBKDF2")
      return out.raw
docs: Interface to PKCS5_PBKDF2_HMAC function
      Parameters:
  
      @param password - password to derive key from
      @param salt - random salt to use for key derivation
      @param outlen - number of bytes to derive
      @param digesttype - name of digest to use to use (default sha1)
      @param iterations - number of iterations to use
  
      @returns outlen bytes of key material derived from password and salt