forked from lxyfirst/id_server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstring_util.h
More file actions
executable file
·64 lines (46 loc) · 1.31 KB
/
Copy pathstring_util.h
File metadata and controls
executable file
·64 lines (46 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* string_util.h
*
* Author: lixingyi (lxyfirst@163.com)
*/
#ifndef STRING_UTIL_H_
#define STRING_UTIL_H_
#include <vector>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
namespace framework
{
std::string& int2str(std::string& str,long int value) ;
int bin2hex(char* hex,const unsigned char* bin,int size) ;
int hex2bin(unsigned char* bin,const char* hex,int size) ;
inline int base64_encode_size(int len)
{
return (((len + 2) / 3) * 4) ;
}
inline int base64_decode_size(int len)
{
return (((len + 3) / 4) * 3) ;
}
int base64_encode(unsigned char* dst,const unsigned char* src,int src_size) ;
int base64_decode(unsigned char* dst,const unsigned char* src,int src_size) ;
struct md5_context
{
uint64_t bytes;
uint32_t a, b, c, d;
unsigned char buffer[64];
} ;
void md5_init(md5_context *ctx);
void md5_update(md5_context *ctx, const void *data, size_t size);
void md5_final(unsigned char result[16], md5_context *ctx);
void md5(std::string& digest,const void *data, int size);
int sql_escape_string(char* buf,int size,const char* data,int data_size) ;
typedef std::vector<std::string> string_vector ;
/*
* @brief split string by seperator
* @return count
*/
int split(string_vector& dst,const char* src,int size,char sep=' ') ;
}
#endif /* STRING_UTIL_H_ */