参考:http://www.jianshu.com/p/8bc791ec42b6
http://www.cnblogs.com/scu-cjx/p/6878853.html
#import <CommonCrypto/CommonDigest.h>
//SHA1加密方式
+(NSString*)sha1WithStr:(NSString *)str
{
const char *cstr = [str cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length: strlen(cstr)];
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;
}