7 if( c >=
'0' && c <=
'9' )
9 if( c >=
'a' && c <=
'f' )
11 if( c >=
'A' && c <=
'F' )
17 std::string
to_hex(
const char* d, uint32_t s )
20 const char*
to_hex=
"0123456789abcdef";
21 uint8_t* c = (uint8_t*)d;
22 for( uint32_t i = 0; i < s; ++i )
27 size_t from_hex(
const std::string& hex_str,
char* out_data,
size_t out_data_len ) {
28 std::string::const_iterator i = hex_str.begin();
29 uint8_t* out_pos = (uint8_t*)out_data;
30 uint8_t* out_end = out_pos + out_data_len;
31 while( i != hex_str.end() && out_end != out_pos ) {
34 if( i != hex_str.end() ) {
40 return out_pos - (uint8_t*)out_data;
42 std::string
to_hex(
const std::vector<char>& data )
45 return to_hex( data.data(), data.size() );