hex2bin()#
hex2bin converts a hexadecimal string into its binary representation, storing the result in a provided buffer.
Prototype
char *hex2bin(
char *bf, /* Output buffer for binary data */
int bfsize, /* Size of the output buffer */
const char *hex, /* Input hexadecimal string */
size_t hex_len, /* Length of the input hexadecimal string */
size_t *out_len /* Output length of the binary data */
);
Parameters
Key |
Type |
Description |
|---|---|---|
|
|
Pointer to the output buffer where the binary data will be stored. |
|
|
Size of the output buffer in bytes. |
|
|
Pointer to the input hexadecimal string to be converted. |
|
|
Length of the input hexadecimal string. |
|
|
Pointer to a variable where the function will store the length of the resulting binary data. |
Return Value
Returns a pointer to the output buffer bf containing the binary data.
Notes
[‘The function processes the input hexadecimal string two characters at a time, converting them into a single byte.’, ‘If a non-hexadecimal character is encountered, the conversion stops.’, ‘The function does not allocate memory; the caller must ensure bf has enough space.’, ‘The out_len parameter is optional; if provided, it will contain the number of bytes written to bf.’]
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples