Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (52 sloc) 2.021 kb
4b4b301c » Matt Patenaude
2009-11-06 got very basics of authorization working properly
1 //
0b6d51a2 » Matt Patenaude
2009-11-07 clean-up for file renaming
2 // NSString+LFExtensions.m
2283d202 » Matt Patenaude
2009-11-16 renamed Last.fm.framework to Scribbler
3 // Scribbler
4b4b301c » Matt Patenaude
2009-11-06 got very basics of authorization working properly
4 //
5 // Created by Matt Patenaude on 11/6/09.
383b0a50 » Matt Patenaude
2009-11-08 updated copyright statements to be more correct
6 // Copyright (C) 2009 {13bold}.
4b4b301c » Matt Patenaude
2009-11-06 got very basics of authorization working properly
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 // THE SOFTWARE.
25 //
26
0b6d51a2 » Matt Patenaude
2009-11-07 clean-up for file renaming
27 #import "NSString+LFExtensions.h"
4b4b301c » Matt Patenaude
2009-11-06 got very basics of authorization working properly
28 #import <CommonCrypto/CommonDigest.h>
29
30
31 NSString *LFHexStringFromBytes(void *bytes, NSUInteger len)
32 {
33 NSMutableString *output = [NSMutableString string];
34
35 unsigned char *input = (unsigned char *)bytes;
36
37 NSUInteger i;
38 for (i = 0; i < len; i++)
39 [output appendFormat:@"%02x", input[i]];
40 return output;
41 }
42
631513c4 » Matt Patenaude
2009-11-07 added UUID support to string extensions
43 @implementation NSString (LFExtensions)
4b4b301c » Matt Patenaude
2009-11-06 got very basics of authorization working properly
44
45 - (NSString *)MD5Hash
46 {
47 const char *input = [self UTF8String];
48 unsigned char result[CC_MD5_DIGEST_LENGTH];
49 CC_MD5(input, strlen(input), result);
50 return LFHexStringFromBytes(result, CC_MD5_DIGEST_LENGTH);
51 }
631513c4 » Matt Patenaude
2009-11-07 added UUID support to string extensions
52 + (NSString *)stringWithNewUUID
53 {
54 CFUUIDRef uuid = CFUUIDCreate(nil);
55 NSString *output = (NSString *)CFUUIDCreateString(nil, uuid);
56 CFRelease(uuid);
57
58 return [output autorelease];
59 }
4b4b301c » Matt Patenaude
2009-11-06 got very basics of authorization working properly
60
61 @end
Something went wrong with that request. Please try again.