The result of the SHA-1 algorithm (which is stored in HMAC
) is a sequence of
bytes, but not a valid UTF-8 sequence. Therefore
[[NSString alloc] initWithData:HMAC encoding:NSUTF8StringEncoding]
fails and returns nil
.
What you probably want is to convert the NSData *HMAC
to a NSString
containing the hexadecimal representation of the data.
There are many solutions available for that, for example How to convert an NSData into an NSString Hex string?.