Created
December 23, 2013 13:06
-
-
Save FrankWu100/8096865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AllPassEncryptorAES.h | |
// AllPassEncryptorAES | |
// | |
// Created by FrankWu on 2013/12/22. | |
// Copyright (c) 2013年 FrankWu. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import <Foundation/NSString.h> | |
@interface AllPassEncryptorAES : NSObject | |
+ (NSString *)saltStr:(NSString *)enStr; | |
+ (NSString *)encryptSaltStrToBase64:(NSString *)str Key:(id)key IV:(id)iv; | |
@end | |
@interface NSString (URLEncode) | |
- (NSString *) URLEncode; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AllPassEncryptorAES.m | |
// AllPassEncryptorAES | |
// | |
// Created by FrankWu on 2013/12/22. | |
// Copyright (c) 2013年 FrankWu. All rights reserved. | |
// | |
#import "AllPassEncryptorAES.h" | |
#import "FWEncryptorAES.h" | |
@implementation AllPassEncryptorAES | |
+ (NSString *)saltStr:(NSString *)enStr | |
{ | |
return [[NSString alloc] initWithFormat:@"%d;%@", (int)[[NSDate date] timeIntervalSince1970], enStr]; | |
} | |
+ (NSString *)encryptSaltStrToBase64:(NSString *)str Key:(id)key IV:(id)iv | |
{ | |
NSParameterAssert([key isKindOfClass: [NSData class]] || [key isKindOfClass: [NSString class]]); | |
NSParameterAssert([iv isKindOfClass: [NSData class]] || [iv isKindOfClass: [NSString class]]); | |
return [FWEncryptorAES encryptStrToBase64:[self saltStr:str] Key:key IV:iv]; | |
} | |
@end | |
@implementation NSString (URLEncode) | |
- (NSString *)URLEncode | |
{ | |
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, | |
(__bridge CFStringRef)self, | |
NULL, | |
CFSTR("!*'();:@&=+$,/?%#[]\" "), | |
kCFStringEncodingUTF8)); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment