code: protected function sign($privateKey, $parameters)
      {
          if (preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', $privateKey, $matches)) {
              $key = $matches[2];
              $key = preg_replace('/\s*/s', '', $key);
              $key = chunk_split($key, 64, "\n");
  
              $key = "-----BEGIN PRIVATE KEY-----\n".$key.'-----END PRIVATE KEY-----';
  
              $digest = $this->sha512Asn1($this->encodeParameters($parameters));
  
              if (@openssl_private_encrypt($digest, $signature, $key)) {
                  return base64_encode($signature);
              }
  
              throw new \InvalidArgumentException('Unable to sign the request, this has to do with the provided (invalid) private key.');
          }
  
          throw new \InvalidArgumentException('Invalid private key.');
      }
docs: Calculate the hash to sign the request with based on the given parameters.
  
  @param string $privateKey Private key to sign the request with
  @param array  $parameters Parameters to sign
  
  @throws \InvalidArgumentException
  
  @return string