Sha256: d1f542eb0342d4f644a0813bb024b1659507bb025b50d081400d82bb81d7003c
Contents?: true
Size: 902 Bytes
Versions: 7
Compression:
Stored size: 902 Bytes
Contents
// // NSData+MD5Digest.m // NSData+MD5Digest // // Created by Francis Chong on 12年6月5日. // #import "NSData+MD5Digest.h" #import <CommonCrypto/CommonDigest.h> @implementation NSData (MD5) +(NSData *)MD5Digest:(NSData *)input { unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(input.bytes, input.length, result); return [[NSData alloc] initWithBytes:result length:CC_MD5_DIGEST_LENGTH]; } -(NSData *)MD5Digest { return [NSData MD5Digest:self]; } +(NSString *)MD5HexDigest:(NSData *)input { unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(input.bytes, input.length, result); NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2]; for (int i = 0; i<CC_MD5_DIGEST_LENGTH; i++) { [ret appendFormat:@"%02x",result[i]]; } return ret; } -(NSString *)MD5HexDigest { return [NSData MD5HexDigest:self]; } @end
Version data entries
7 entries across 7 versions & 2 rubygems