Function anj_hexlify

Function Documentation

int anj_hexlify(char *out_buff, size_t out_buff_size, const void *data, size_t data_len)

Encode a byte buffer as an uppercase hexadecimal string.

The hexlified buffer is guaranteed to be NULL-terminated after the function returns.

The caller must provide an output buffer large enough to hold the whole result together with the terminating null character, i.e. at least 2 * data_len + 1 bytes.

Parameters:
  • out_buff[out] Output buffer for the null-terminated hex string.

  • out_buff_size – Size of out_buff in bytes.

  • data – Input byte buffer.

  • data_len – Length of data in bytes.

Returns:

0 on success, -1 if out_buff is too small.