public function OAuthSignatureMethod_HMAC::build_signature in OAuth 1.0 7.4
Same name and namespace in other branches
- 6.3 includes/OAuthSignatureMethod_HMAC.inc \OAuthSignatureMethod_HMAC::build_signature()
- 7.3 includes/OAuthSignatureMethod_HMAC.inc \OAuthSignatureMethod_HMAC::build_signature()
File
- includes/
OAuthSignatureMethod_HMAC.inc, line 51
Class
- OAuthSignatureMethod_HMAC
- A generic signature method implementation that leverages hash_hmac() for increased flexibility.
Code
public function build_signature($request, $consumer, $token) {
$base_string = $request
->get_signature_base_string();
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
$token ? $token->secret : "",
);
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac($this->algo, $base_string, $key, TRUE));
}