//
// GTMBase64.h
//
// Copyright 2006-2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
// David Lee make changes:
// Remove dependency on GTMDefines.h
// add some string to string function
#import <Foundation/Foundation.h>
// GTMBase64
//
/// Helper for handling Base64 and WebSafeBase64 encodings
//
/// The webSafe methods use different character set and also the results aren't
/// always padded to a multiple of 4 characters. This is done so the resulting
/// data can be used in urls and url query arguments without needing any
/// encoding. You must use the webSafe* methods together, the data does not
/// interop with the RFC methods.
//
@interface GTMBase64 : NSObject
//
// Standard Base64 (RFC) handling
//
// encodeData:
//
/// Base64 encodes contents of the NSData object.
//
/// Returns:
/// A new autoreleased NSData with the encoded payload. nil for any error.
//
+(NSData *)encodeData:(NSData *)data;
// decodeData:
//
/// Base64 decodes contents of the NSData object.
//
/// Returns:
/// A new autoreleased NSData with the decoded payload. nil for any error.
//
+(NSData *)decodeData:(NSData *)data;
// encodeBytes:length:
//
/// Base64 encodes the data pointed at by |bytes|.
//
/// Returns:
/// A new autoreleased NSData with the encoded payload. nil for any error.
//
+(NSData *)encodeBytes:(const void *)bytes length:(NSUInteger)length;
// decodeBytes:length:
//
/// Base64 decodes the data pointed at by |bytes|.
//
/// Returns:
/// A new autoreleased NSData with the encoded payload. nil for any error.
//
+(NSData *)decodeBytes:(const void *)bytes length:(NSUInteger)length;
// stringByEncodingData:
//
/// Base64 encodes contents of the NSData object.
//
/// Returns:
/// A new autoreleased NSString with the encoded payload. nil for any error.
//
+(NSString *)stringByEncodingData:(NSData *)data;
// stringByEncodingBytes:length:
//
/// Base64 encodes the data pointed at by |bytes|.
//
/// Returns:
/// A new autoreleased NSString with the encoded payload. nil for any error.
//
+(NSString *)stringByEncodingBytes:(const void *)bytes length:(NSUInteger)length;
// decodeString:
//
/// Base64 decodes contents of the NSString.
//
/// Returns:
/// A new autoreleased NSData with the decoded payload. nil for any error.
//
+(NSData *)decodeString:(NSString *)string;
//
// Modified Base64 encoding so the results can go onto urls.
//
// The changes are in the characters generated and also allows the result to
// not be padded to a multiple of 4.
// Must use the matching call to encode/decode, won't interop with the
// RFC versions.
//
// webSafeEncodeData:padded:
//
/// WebSafe Base64 encodes contents of the NSData object. If |padded| is YES
/// then padding characters are added so the result length is a multiple of 4.
//
/// Returns:
/// A new autoreleased NSData with the encoded payload. nil for any error.
//
+(NSData *)webSafeEncodeData:(NSData *)data
padded:(BOOL)padded;
// webSafeDecodeData:
//
/// WebSafe Base64 decodes contents of the NSData object.
//
/// Returns:
/// A new autoreleased NSData with the decoded payload. nil for any error.
//
+(NSData *)webSafeDecodeData:(NSData *)data;
// webSafeEncodeBytes:length:padded:
//
/// WebSafe Base64 encodes the data pointed at by |bytes|. If |padded| is YES
/// then padding characters are added so the result length is a multiple of 4.
//
/// Returns:
/// A new autoreleased NSData with the encoded payload. nil for any error.
//
+(NSData *)webSafeEncodeBytes:(const void *)bytes
length:(NSUInteger)length
padded:(BOOL)padded;
// webSafeDecodeBytes:length:
//
/// WebSafe Base64 decodes the data pointed at by |bytes|.
//
/// Returns:
/// A new autoreleased NSData with the encoded payload. nil for any error.
//
+(NSData *)webSafeDecodeBytes:(const void *)bytes length:(NSUInteger)length;
// stringByWebSafeEncodingData:padded:
//
/// WebSafe Base64 encodes contents of the NSData object. If |padded| is YES
/// then padding characters are added so the result length is a multiple of 4.
//
/// Returns:
/// A new autoreleased NSString with the encoded payload. nil for any error.
//
+(NSString *)stringByWebSafeEncodingData:(NSData *)data
padded:(BOOL)padded;
// stringByWebSafeEncodingBytes:length:padded:
//
/// WebSafe Base64 encodes the data pointed at by |bytes|. If |padded| is YES
/// then padding characters are added so the result length is a multiple of 4.
//
/// Returns:
/// A new autoreleased NSString with the encoded payload. nil for any error.
//
+(NSString *)stringByWebSafeEncodingBytes:(const void *)bytes
length:(NSUInteger)length
padded:(BOOL)padded;
// webSafeDecodeString:
//
/// WebSafe Base64 decodes contents of the NSString.
//
/// Returns:
/// A new autoreleased NSData with the decoded payload. nil for any error.
//
+(NSData *)webSafeDecodeString:(NSString *)string;
// David Lee new added function
/// Returns:
// A new autoreleased NSString with Base64 encoded NSString
+(NSString *)stringByBase64String:(NSString *)base64String;
// David Lee new added function
/// Returns:
// A new autoreleased Base64 encoded NSString with NSString
+(NSString *)base64StringBystring:(NSString *)string;
@end
iOS开发 GTMBase64文件
5星 · 超过95%的资源 需积分: 12 4 浏览量
2014-08-28
16:00:32
上传
评论
收藏 7KB RAR 举报
在枫中_
- 粉丝: 0
- 资源: 1
最新资源
- 客流量预测.rar客流量预测.rar客流量预测.rar
- 613155687470549安卓鸿蒙手机版_10.7.6.6.apk
- 基于51单片机的蓝牙避障小车源码.zip
- esp8266wifi模块教程: 《嵌入式编程与网络通信:C语言操作ESP8266 WiFi模块》-涵盖嵌入式系统、网络编程、
- 毕业设计基于SSM和SpringBoot的动态旅游网站.zip
- 基于51单片机的mp3播放器源码+原理图+参考资料.zip
- 随机森林回归预测模型的构建与应用.zip
- 《Python文本挖掘实战:词频统计高效教程》-计算机科学·Python编程·文本分析·数据预处理
- 基于51单片机的自动浇水器设计源码+原理图pcb+使用说明.zip
- 《机器学习评估:Python混淆矩阵实战》-涵盖模型评估、分类算法,助力精准度与召回率分析,适用于数据科学和人工智能领域
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页