mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-02 22:42:45 +08:00
* Introduces RKRequestCache for cacheing responses (supports ETag conditional GET, use cache if available, use cache on error, etc.) closes #75 * Updates to Three20 layer to eliminate need for intermediary TTTableItem classes closes #76 * Fixes to ensure iOS 3.x compatability: * Switched compiler to Clang * Updated conditional checks for UIBackgroundTask symbols to ensure runtime safety on iOS 3.x * Removed unnecessary linkage against UIKit and CoreFoundation from library targets * Fix for issue where RKRequest objects could become stuck in infinite loop within RKRequestQueue loadNextInQueue if you start a request and then cancel immediately. On cancel only decrement loadCount if the request has start loading. refs #122
34 lines
782 B
Objective-C
34 lines
782 B
Objective-C
//
|
|
// NSString+MD5.m
|
|
// RestKit
|
|
//
|
|
// Created by Jeff Arena on 4/4/11.
|
|
// Copyright 2011 Two Toasters. All rights reserved.
|
|
//
|
|
|
|
#import "NSString+MD5.h"
|
|
#import <CommonCrypto/CommonDigest.h>
|
|
|
|
@implementation NSString (MD5)
|
|
|
|
- (NSString*)MD5 {
|
|
// Create pointer to the string as UTF8
|
|
const char* ptr = [self UTF8String];
|
|
|
|
// Create byte array of unsigned chars
|
|
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
|
|
|
|
// Create 16 byte MD5 hash value, store in buffer
|
|
CC_MD5(ptr, strlen(ptr), md5Buffer);
|
|
|
|
// Convert MD5 value in the buffer to NSString of hex values
|
|
NSMutableString* output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
|
|
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
|
|
[output appendFormat:@"%02x",md5Buffer[i]];
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
@end
|