-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSString+URLEncoding.m
executable file
·40 lines (31 loc) · 1.25 KB
/
NSString+URLEncoding.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// NSString+URLEncoding.m
// IdeaFlasher Authentication
//
// Created by Christian Hansen on 24/11/12.
// Copyright (c) 2012 Kwamecorp. All rights reserved.
//
#import "NSString+URLEncoding.h"
@implementation NSString (URLEncoding)
- (NSString *)utf8AndURLEncode
{
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)self,
NULL,
(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)));
}
+ (NSString *)getUUID
{
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidStr = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
return uuidStr;
}
+ (NSString *)getNonce
{
// uuid is simplified a bit, also the full uuid can be used as nonce
NSString *uuid = [self getUUID];
return [[uuid substringToIndex:10] stringByReplacingOccurrencesOfString:@"-" withString:@""].lowercaseString;
}
@end