src/util/string.h
/**
 * string_to_hex() - encode string as ascii-hex
 * @str:        string to encode from
 * @n:          length of @str in bytes
 * @hex:        destination buffer
 *
 * This hex-encodes the source string into the destination buffer. The
 * destination buffer must be at least twice as big as the source.
 */
encode string as ascii-hex
@str:        string to encode from
@n:          length of @str in bytes
@hex:        destination buffer

This hex-encodes the source string into the destination buffer. The
destination buffer must be at least twice as big as the source.
encode string as ascii - hex @str : string to encode from @n : length of @str in bytes @hex : destination buffer This hex - encodes the source string into the destination buffer . The destination buffer must be at least twice as big as the source .
static inline void string_to_hex(const char *str, size_t n, char *hex) {
        static const char table[16] = "0123456789abcdef";
        while (n--) {
                *hex++ = table[(*str >> 4) & 0x0f];
                *hex++ = table[(*str++) & 0x0f];
        }
}
static inline void string_to_hex ( const char * str , size_t n , char * hex ) { static const char table [ 16 ] = " " ; while ( n -- ) { * hex ++ = table [ ( * str >> 4 ) & 0x0f ] ; * hex ++ = table [ ( * str ++ ) & 0x0f ] ; } }
string_to_hex() - encode string as ascii-hex
 @str:        string to encode from
 @n:          length of @str in bytes
 @hex:        destination buffer
string_to_hex () - encode string as ascii - hex @str : string to encode from @n : length of @str in bytes @hex : destination buffer