// // KXMD5Manager.m // CAISHEN // // Created by jikaipeng on 2017/9/27. // Copyright © 2017年 kuxuan. All rights reserved. // #import "KXMD5Manager.h" #import @implementation KXMD5Manager + (instancetype)sharedInstance{ static KXMD5Manager *md5Manager = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ if (md5Manager == nil) { md5Manager = [[KXMD5Manager alloc] init]; } }); return md5Manager; } - (NSString *) md5:(NSString *) input { const char *cStr = [input UTF8String]; unsigned char digest[CC_MD5_DIGEST_LENGTH]; CC_MD5( cStr, strlen(cStr), digest ); // This is the md5 call NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) [output appendFormat:@"%02x", digest[i]]; return output; } @end