title: Different HMac Digest are being generated every time for the same input in objective c
body: <p>Trying to get the digest using <code>HMac SHA256</code> with below code but every time it is giving different output.</p>
  
  <p>Here key parameter is in <code>Base64string</code> format while plaintext parameter is without any encoding.</p>
  
  <pre><code>+(NSString *)hmacWithIndicies:(NSString *)plaintext withKey:(NSString *)key {
   NSLog(@"Input text::%@",plaintext);
   NSLog(@"Input Key::%@",key);
   NSData *keyData = [[NSData alloc] initWithBase64EncodedString:key options:0];
   NSLog(@"Key Data is::%@",keyData);
   const char *cKey = (char *)[keyData bytes];
  
   NSLog(@"Key Length is::%lu",strlen(cKey));
   NSData *keyInData = [NSData dataWithBytes:cKey length:sizeof(cKey)];
   NSLog(@"Key data = %@", keyInData);
  
  //Data here
   const char *cData = [plaintext cStringUsingEncoding:NSUTF8StringEncoding];
   NSLog(@"Input Length is::%lu",strlen(cData));
  
   NSData *dataData = [NSData dataWithBytes:cData length:sizeof(cData)];
   NSLog(@"Input data = %@", dataData);
  
   uint8_t cHMAC[CC_SHA256_DIGEST_LENGTH];
  
   CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
  
   NSData *hMacInData =[[NSData alloc] initWithBytes:cHMAC length:sizeof(cHMAC)];
   NSLog(@"Hash Mac data generated is %@", hMacInData);
   NSString *b64EncStrHmac = [hMacInData base64EncodedStringWithOptions:0];
  
   NSLog(@"Hash Mac generated is %@", b64EncStrHmac);
  
   return b64EncStrHmac;
  
  }
  </code></pre>
  
  <p>Calling the above method as below:-</p>
  
  <pre><code>NSString * hMacOutput= [KeyGeneration hmacWithIndicies:@"2SagarPra2983688" withKey:@"qDwki5t1SSuKER4mzSMBHXhtt+PRMCv0B2LgXaBZmgE="];
  
  NSLog(@"Output of HMac digest::%@",hMacOutput);
  </code></pre>
  
  <p><code>hMacOutput</code> digest is resulting in different output every time it is being called.</p>