add .gitignore
This commit is contained in:
24
msext/Class/webCache/NSString+Sha1.m
Executable file
24
msext/Class/webCache/NSString+Sha1.m
Executable file
@@ -0,0 +1,24 @@
|
||||
|
||||
#import "NSString+Sha1.h"
|
||||
|
||||
@implementation NSString (Sha1)
|
||||
|
||||
- (NSString *)sha1
|
||||
{
|
||||
// see http://www.makebetterthings.com/iphone/how-to-get-md5-and-sha1-in-objective-c-ios-sdk/
|
||||
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
|
||||
|
||||
CC_SHA1(data.bytes, (CC_LONG)data.length, digest);
|
||||
|
||||
NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
|
||||
|
||||
for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
|
||||
[output appendFormat:@"%02x", digest[i]];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user