@interface
NSString
(util)
#pragma mark - base64
+ (
NSString
*)encodeBase64String:(
NSString
*)input;
+ (
NSString
*)decodeBase64String:(
NSString
*)input;
+ (
NSString
*)encodeBase64Data:(
NSData
*)data;
+ (
NSString
*)decodeBase64Data:(
NSData
*)data;
@end
#import "ExtendNSString.h"
#import "GTMBase64.h"
static
const
char
encodingTable[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
;
@implementation
NSString
(util)
#pragma mark - base64
+ (
NSString
*)encodeBase64String:(
NSString
* )input {
NSData
*data = [input dataUsingEncoding:
NSUTF8StringEncoding
allowLossyConversion:
YES
];
data = [GTMBase64 encodeData:data];
NSString
*base64String = [[
NSString
alloc] initWithData:data encoding:
NSUTF8StringEncoding
];
return
base64String;
}
+ (
NSString
*)decodeBase64String:(
NSString
* )input {
NSData
*data = [input dataUsingEncoding:
NSUTF8StringEncoding
allowLossyConversion:
YES
];
data = [GTMBase64 decodeData:data];
NSString
*base64String = [[
NSString
alloc] initWithData:data encoding:
NSUTF8StringEncoding
];
return
base64String;
}
+ (
NSString
*)encodeBase64Data:(
NSData
*)data {
data = [GTMBase64 encodeData:data];
NSString
*base64String = [[
NSString
alloc] initWithData:data encoding:
NSUTF8StringEncoding
];
return
base64String;
}
+ (
NSString
*)decodeBase64Data:(
NSData
*)data {
data = [GTMBase64 decodeData:data];
NSString
*base64String = [[
NSString
alloc] initWithData:data encoding:
NSUTF8StringEncoding
];
return
base64String;
}
@end