title: Using CommonCrypto/CommonHMAC to encrypt some data and always comes back null
body: <p>I tried the following to encrypt the <code>clearTextData</code> using the key <code>keyData</code>. And I did check to make sure that both of those values are valid and going through.</p>
  
  <pre><code>NSData *keyData = [PRIVATE_KEY dataUsingEncoding:NSUTF8StringEncoding];
  NSData *clearTextData = [data dataUsingEncoding:NSUTF8StringEncoding];
  
  uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};
  
  CCHmacContext hmacContext;
  CCHmacInit(&amp;hmacContext, kCCHmacAlgSHA1, keyData.bytes, keyData.length);
  CCHmacUpdate(&amp;hmacContext, clearTextData.bytes, clearTextData.length);
  CCHmacFinal(&amp;hmacContext, digest);
  
  NSData *out = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
  
  NSLog(@"encrypted data: %@", [NSString stringWithUTF8String:[out bytes]]);
  </code></pre>
  
  <p>The log always comes back saying <code>encrypted data: (null)</code></p>
  
  <p>Any ideas?</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>Here are examples of the key and data that I am passing:</p>
  
  <blockquote>
    <p>key: 983745hjhgfd3454</p>
    
    <p>data:
    {"data":"lala","pubKey":"75948458","sig":"val"}</p>
  </blockquote>