| 123456789101112131415161718192021222324252627 |
- //
- // NSString+XHMD5.m
- // XHImageViewer
- //
- // Created by 曾 宪华 on 14-2-18.
- // Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群(142557668). All rights reserved.
- //
- #import "NSString+XHMD5.h"
- #import <CommonCrypto/CommonCrypto.h>
- @implementation NSString (XHMD5)
- - (NSString *)MD5Hash {
- if(self.length == 0) { return nil; }
-
- const char *cStr = [self UTF8String];
- unsigned char result[16];
- CC_MD5(cStr, (CC_LONG)strlen(cStr), result);
-
- return [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
- 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]];
- }
- @end
|