title: SHA-1 hash for HMAC Generated in Objective C and PHP (hash_hmac) dont match
body: <p>I am trying to implement HMAC authentication from Objective C(CCHmac) and PHP (hash_hmac). I got the different hash result. Have anyone can help me? I don't know why to get the different hash result? Below is my Code (Objective-c &amp; PHP) for your reference. Please!</p>
  
  <p>PHP: </p>
  
  <pre><code>$APIConsumerSecret ="DcmzvkQC7Sno+lxnbDG0hTtZ0WTQn9T2T9DJxEmcB0";
  $APIConsumerSecret = urlencode($APIConsumerSecret).'&amp;';
  $BaseString="GET&amp;http%3A%2F%2Fboday.api.simppo.com%2Foauth%2Frequest_token&amp;oauth_consumer_key%3DCN6W1I8E2CEWZJNQI2KA7KY3%26oauth_nonce%3DlxTSJL%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1357268295%26oauth_version%3D1.0";
  
  echo base64_encode(hash_hmac('sha1',$BaseString,$APIConsumerSecret,true));
  </code></pre>
  
  <p>PHP Result: <code>xJ5Ya4u4ghH4ugIieGIb9AcFpD0=</code></p>
  
  <p>Objective-C</p>
  
  <pre><code>- (NSString*)flickr_oauthSignatureFor:(NSString*)dataString withKey:(NSString*)secret
  {
    NSData* secretData = [secret dataUsingEncoding:NSUTF8StringEncoding];
    NSData* stringData = [dataString dataUsingEncoding:NSUTF8StringEncoding];
  
    const void* keyBytes = [secretData bytes];
    const void* dataBytes = [stringData bytes];
  
    ///#define CC_SHA1_DIGEST_LENGTH   20          /* digest length in bytes */
    void* outs = malloc(CC_SHA1_DIGEST_LENGTH);
  
    CCHmac(kCCHmacAlgSHA1, keyBytes, [secretData length], dataBytes, [stringData length], outs);
  
    // Soluion 1
    NSData* signatureData = [NSData dataWithBytesNoCopy:outs length:CC_SHA1_DIGEST_LENGTH freeWhenDone:YES];
  
    NSLog(@"D1-0: signatureData %@", signatureData );
    NSLog(@"base64:%@", [signatureData base64EncodedString] );
  
    return [signatureData base64EncodedString];
  }
  </code></pre>
  
  <p>Objective-C Result: </p>
  
  <pre><code>D1-0: &lt;59052771 e670a04b 3a2e87db 3d7965be 1aed112e&gt;
  base64: WQUnceZwoEs6LofbPXllvhrtES4=
  </code></pre>