QNUrlSafeBase64.m 689 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // QiniuSDK
  3. //
  4. // Created by bailong on 14-9-28.
  5. // Copyright (c) 2014年 Qiniu. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "QNUrlSafeBase64.h"
  9. #import "QN_GTM_Base64.h"
  10. @implementation QNUrlSafeBase64
  11. + (NSString *)encodeString:(NSString *)sourceString {
  12. NSData *data = [NSData dataWithBytes:[sourceString UTF8String] length:[sourceString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
  13. return [self encodeData:data];
  14. }
  15. + (NSString *)encodeData:(NSData *)data {
  16. return [QN_GTM_Base64 stringByWebSafeEncodingData:data padded:YES];
  17. }
  18. + (NSData *)decodeString:(NSString *)data {
  19. return [QN_GTM_Base64 webSafeDecodeString:data];
  20. }
  21. @end