0

Expecting these series of functions to produce a 32 character long signature for authenticating via OAuth v1.

    $h = hash_hmac("sha1", $url, $key, $raw_output=TRUE);
    $signature = base64_encode($h);

However it's consistently producing a 30 character long signature even when I change the $url parameters. Am I understanding how to create OAuth signatures?

Dylan Pierce
  • 4,313
  • 3
  • 35
  • 45

1 Answers1

0

sha1 produces 20 bytes. Since base64 will increase the string length as mentioned here this will produce a string 28 characters long (this may be longer if you call urlencode on the signature).

I'm not as familiar with oauth but there doesn't seem to be anything in the spec which mandates a 32 character signature.

Community
  • 1
  • 1
Jim
  • 22,354
  • 6
  • 52
  • 80