#include <stdlib.h>
#include "core.h"
#include "types.h"
Go to the source code of this file.
|
void | hex_enc (const void *in_raw, size_t len, void *out_enc, size_t out_cap) |
|
bool_t | hex_dec (const void *in_enc, size_t len, void *out_raw, size_t out_cap) |
|
◆ hex_dec()
bool_t hex_dec |
( |
const void * |
in_enc, |
|
|
size_t |
len, |
|
|
void * |
out_raw, |
|
|
size_t |
out_cap |
|
) |
| |
Decodes a string of hex characters into a binary output buffer.
- Parameters
-
in_enc | Input string of hex characters. This must NOT contain any whitespace. It must be strictly ONLY the hex characters. The input doesn't need to be NUL-terminated (length is provided explicitly in the len parameter). |
len | Number of characters in the in_enc buffer (excluding any terminating NUL bytes). This must be a multiple of 2. |
out_raw | Output binary buffer, which will be filled with the decoded data. |
out_cap | Output buffer length in bytes. This must be at least half of len . |
- Returns
B_TRUE
if decoding succeeded, B_FALSE
otherwise. Decoding failure can occur if the input doesn't contain an even number of characters, the output buffer is too small to contain the entire decoded input, or if an invalid (non-hex) character is encountered in the input buffer.
Definition at line 84 of file hexcode.c.
◆ hex_enc()
void hex_enc |
( |
const void * |
in_raw, |
|
|
size_t |
len, |
|
|
void * |
out_enc, |
|
|
size_t |
out_cap |
|
) |
| |
Encodes binary data into a string of hex digits.
- Parameters
-
in_raw | Input binary data buffer to be encoded. |
len | Input binary buffer length in bytes. |
out_enc | Output buffer to hold the string of encoded hex characters. The output is guaranteed to always be zero-terminated (provided the buffer can hold at least 1 byte). |
out_cap | Output buffer capacity. To properly encode all input into the output, the output buffer must be able to hold at least twice len bytes plus 1 (for the terminating NUL byte). |
Definition at line 38 of file hexcode.c.