fastdo  0.6.8
encoding.hpp
浏览该文件的文档.
1 #ifndef __ENCODING_HPP__
2 #define __ENCODING_HPP__
3 //
4 // encoding 提供编码与解码相关的功能
5 //
6 
7 namespace winux
8 {
9 
16 WINUX_FUNC_DECL(String) UrlEncode( String const & str );
17 
19 WINUX_FUNC_DECL(String) UrlDecode( String const & str );
20 
26 
29 
31 WINUX_FUNC_DECL(String) HtmlEncode( String const & str );
32 
34 WINUX_FUNC_DECL(String) HtmlDecode( String const & str );
35 
36 
38 WINUX_FUNC_DECL(String) Base64Encode( void const * buf, size_t size );
42 inline String Base64Encode( Buffer const & buf ) { return Base64Encode( buf.getBuf(), buf.getSize() ); }
44 WINUX_FUNC_DECL(AnsiString) Base64Decode( String const & base64Str );
45 
47 WINUX_FUNC_DECL(String) Md5Hex( void const * buf, size_t size );
49 inline String Md5Hex( Buffer const & buf ) { return Md5Hex( buf.getBuf(), buf.getSize() ); }
50 
52 WINUX_FUNC_DECL(String) Sha1Hex( void const * buf, size_t size );
54 inline String Sha1Hex( Buffer const & buf ) { return Sha1Hex( buf.getBuf(), buf.getSize() ); }
56 WINUX_FUNC_DECL(Buffer) Sha1( void const * buf, size_t size );
58 inline Buffer Sha1( Buffer const & buf ) { return Sha1( buf.getBuf(), buf.getSize() ); }
59 
60 
63 {
67 };
68 
70 WINUX_FUNC_DECL(int) RawEncrypt( byte const * data, size_t dataSize, byte * buf, size_t bufSize, size_t * outSize );
72 WINUX_FUNC_DECL(int) RawDecrypt( byte const * encryptData, size_t dataSize, byte * buf, size_t bufSize, size_t * outSize );
73 
77 WINUX_FUNC_DECL(Buffer) EncryptContent( Buffer const & content );
79 WINUX_FUNC_DECL(AnsiString) DecryptContent( AnsiString const & encryptContent );
81 WINUX_FUNC_DECL(Buffer) DecryptContent( Buffer const & encryptContent );
82 
83 #define EncryptCArray(data) EncryptContent( CBufferToAnsiString( data, sizeof(data) ) )
84 #define EncryptCBuffer( buf, size ) EncryptContent( CBufferToAnsiString( buf, size ) )
85 #define DecryptCArray(data) DecryptContent( CBufferToAnsiString( data, sizeof(data) ) )
86 #define DecryptCBuffer( buf, size ) DecryptContent( CBufferToAnsiString( buf, size ) )
87 
88 
89 } // namespace winux
90 
91 #endif // __ENCODING_HPP__
XString< char > AnsiString
Definition: utilities.hpp:212
void * getBuf() const
暴露缓冲区指针
Definition: utilities.hpp:585
XString< tchar > String
Definition: utilities.hpp:216
Buffer Sha1(void const *buf, size_t size)
将数据进行sha1编码,返回二进制数据
size_t getSize() const
获取数据大小
Definition: utilities.hpp:613
AnsiString EncryptContent(AnsiString const &content)
内容加密
AnsiString DecryptContent(AnsiString const &encryptContent)
内容解密,与EncryptContent()配套
int RawDecrypt(byte const *encryptData, size_t dataSize, byte *buf, size_t bufSize, size_t *outSize)
未进行C++包装的内容解密,与RawEncrypt()配套
String UriComponentEncode(String const &str)
URI组成部分编码,遵循RFC1738.
缓冲区,表示内存中一块二进制数据(利用malloc/realloc进行内存分配)
Definition: utilities.hpp:528
int RawEncrypt(byte const *data, size_t dataSize, byte *buf, size_t bufSize, size_t *outSize)
未进行C++包装的内容加密
String HtmlEncode(String const &str)
HTML编码 作用字符:&#39;&&#39;, &#39;<&#39;, &#39;>&#39;, &#39; &#39;.
String Base64Encode(void const *buf, size_t size)
Base64编码
AnsiString Base64Decode(String const &base64Str)
Base64解码,与Base64Encode()配套
String Sha1Hex(void const *buf, size_t size)
将数据进行sha1编码,返回16进制数字符串
#define WINUX_FUNC_DECL(ret)
Definition: utilities.hpp:64
String UriComponentDecode(String const &str)
URI组成部分解码,与UriComponentEncode()配套
unsigned char byte
Definition: utilities.hpp:204
String UrlEncode(String const &str)
URL编码
String UrlDecode(String const &str)
URL解码,与UrlEncode()配套
String Md5Hex(void const *buf, size_t size)
将数据进行md5编码,返回16进制数字符串
EncryptErrorCode
内容加密错误代码
Definition: encoding.hpp:62
String HtmlDecode(String const &str)
HTML解码,与HtmlEncode()配套
跨平台基础功能库
Definition: archives.hpp:7