/NSDataMd5.m
http://rtm2cocoa.googlecode.com/ · Objective C · 42 lines · 16 code · 6 blank · 20 comment · 1 complexity · a54a9bd67963cc3f92ce50a9297503fd MD5 · raw file
- /*
- * NSDataMd5.m
- * RTMApiTest
- *
- * Created by kkillian on 17/11/09.
- * Copyright 2009 shufflecodebox. All rights reserved.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- #import "NSDataMd5.h"
- @implementation NSData (NSDataMd5)
- - (NSString *)hexval
- {
- NSMutableString *hex = [NSMutableString string];
- unsigned char *bytes = (unsigned char *)[self bytes];
- char temp[3];
- int i = 0;
-
- for (i = 0; i < [self length]; i++) {
- temp[0] = temp[1] = temp[2] = 0;
- (void)sprintf(temp, "%02x", bytes[i]);
- [hex appendString:[NSString stringWithUTF8String:temp]];
- }
-
- return hex;
- }
- @end