4 * Copyright (c) 2007 Andy Smith
6 namespace Abraham\TwitterOAuth;
9 * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
10 * where the Signature Base String is the text and the key is the concatenated values (each first
11 * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
12 * character (ASCII code 38) even if empty.
13 * - Chapter 9.2 ("HMAC-SHA1")
15 class HmacSha1 extends SignatureMethod
20 public function getName()
28 public function buildSignature(Request $request, Consumer $consumer, Token $token = null)
30 $signatureBase = $request->getSignatureBaseString();
32 $parts = [$consumer->secret, null !== $token ? $token->secret : ""];
34 $parts = Util::urlencodeRfc3986($parts);
35 $key = implode('&', $parts);
37 return base64_encode(hash_hmac('sha1', $signatureBase, $key, true));