用给时间进行加密做例子:
NSDate * senddate=[NSDate date];
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"YYYY-MM-dd"];
NSString * locationString=[dateformatter stringFromDate:senddate];
NSString *str = [locationString stringByAppendingString:@"tt.xmdj123.com"];
NSString *string = [self MD5With:str];
MD5加密方法:
-(NSMutableString *)MD5With:(NSString *)str{
const char *cStr = [str UTF8String];
unsigned char digest[CC_MD5_DIGEST_LENGTH];
CC_MD5( cStr, str.length, digest );
NSMutableString *result = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
[result appendFormat:@"%02x", digest[i]];
return result;
}