Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 978df85573
Fetching contributors…

Cannot retrieve contributors at this time

executable file 46 lines (37 sloc) 1.602 kb
////////////////////////////////////////////////////////////////////////////////
//
// EXPANZ
// Copyright 2008-2011 EXPANZ
// All Rights Reserved.
//
// NOTICE: Expanz permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import "XCKeyBuilder.h"
#import "XCMemoryUtils.h"
@implementation XCKeyBuilder
/* ================================================= Class Methods ================================================== */
+ (XCKeyBuilder*) forItemNamed:(NSString*)name {
NSData* data = [name dataUsingEncoding:NSUTF8StringEncoding];
return XCAutorelease([[XCKeyBuilder alloc] initHashValueMD5HashWithBytes:[data bytes] length:[data length]]);
}
/* ================================================== Initializers ================================================== */
- (id) initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length {
self = [super init];
if (self != nil) {
CC_MD5(bytes, (int) length, _value);
}
return self;
}
/* ================================================ Interface Methods =============================================== */
- (NSString*) build {
NSInteger byteLength = sizeof(HashValueMD5Hash);
NSMutableString* stringValue = [NSMutableString stringWithCapacity:byteLength * 2];
NSInteger i;
for (i = 0; i < byteLength; i++) {
[stringValue appendFormat:@"%02x", _value[i]];
}
return [stringValue substringToIndex:24];
}
@end
Jump to Line
Something went wrong with that request. Please try again.