md5 加密

xiaoxiao2021-02-28  5

记录一下 用到的方法

头文件

#import <CommonCrypto/CommonDigest.h>

//32位大写

+ (NSString *)md532BitUpper:(NSString *)string{     const char *cStr = [string UTF8String];     unsigned char result[16];          NSNumber *num = [NSNumber numberWithUnsignedLong:strlen(cStr)];     CC_MD5( cStr,[num intValue], result );          return [[NSString stringWithFormat:              @"XXXXXXXXXXXXXXXX",              result[0], result[1], result[2], result[3],              result[4], result[5], result[6], result[7],              result[8], result[9], result[10], result[11],              result[12], result[13], result[14], result[15]              ] uppercaseString]; }

//32位小写

+ (NSString*)md532BitLower:(NSString *)string {     const char *cStr = [string UTF8String];     unsigned char result[16];          NSNumber *num = [NSNumber numberWithUnsignedLong:strlen(cStr)];     CC_MD5( cStr,[num intValue], result );          return [[NSString stringWithFormat:              @"XXXXXXXXXXXXXXXX",              result[0], result[1], result[2], result[3],              result[4], result[5], result[6], result[7],              result[8], result[9], result[10], result[11],              result[12], result[13], result[14], result[15]              ] lowercaseString]; }

转载请注明原文地址: https://www.6miu.com/read-1649988.html

最新回复(0)