Primeiro, importe CommonDigest.h de CommonCrypto
#import <CommonCrypto/CommonDigest.h>
Em seguida, cole este código de amostra onde você precisa:
-(NSString*) returnHashWithSHA1:(NSString*)inputText {
const char *cstr = [inputText cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:inputText.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, data.length, digest);
NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x", digest[i]];
}
return output;
}