mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
rewrite ff_data_to_hex
This commit is contained in:
parent
e9cb8210fc
commit
ac6b37de4b
3 changed files with 13 additions and 20 deletions
|
@ -1051,25 +1051,18 @@ int srs_do_create_dir_recursively(string dir)
|
|||
return c;
|
||||
}
|
||||
|
||||
char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
|
||||
char *srs_data_to_hex(char *des,const u_int8_t *src,int len)
|
||||
{
|
||||
int i;
|
||||
static const char hex_table_uc[16] = { '0', '1', '2', '3',
|
||||
'4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B',
|
||||
'C', 'D', 'E', 'F' };
|
||||
static const char hex_table_lc[16] = { '0', '1', '2', '3',
|
||||
'4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b',
|
||||
'c', 'd', 'e', 'f' };
|
||||
const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
|
||||
|
||||
for (i = 0; i < s; i++) {
|
||||
buff[i * 2] = hex_table[src[i] >> 4];
|
||||
buff[i * 2 + 1] = hex_table[src[i] & 0xF];
|
||||
}
|
||||
|
||||
return buff;
|
||||
if(src == NULL || len == 0 || des == NULL){
|
||||
return NULL;
|
||||
}
|
||||
const char *hex_table = "0123456789ABCDEF";
|
||||
for (int i=0; i<len; i++) {
|
||||
des[i * 2] = hex_table[src[i] >> 4];
|
||||
des[i * 2 + 1] = hex_table[src[i] & 0x0F];
|
||||
}
|
||||
|
||||
return des;
|
||||
}
|
||||
|
||||
int ff_hex_to_data(uint8_t* data, const char* p)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue