Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_hex.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
26
27#ifndef __NILOREA_HEX_HEADER
28#define __NILOREA_HEX_HEADER
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "nilorea/n_str.h"
35
36#include <stddef.h>
37
42
44N_STR* n_hex_encode(const unsigned char* data, size_t len);
45
47unsigned char* n_hex_decode(const char* hex, size_t* out_len);
48
50size_t n_hex_encode_to(char* out, size_t out_size, const unsigned char* data, size_t len);
51
53int n_hex_decode_to(unsigned char* out, size_t out_size, const char* hex, size_t nbytes);
54
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif /* __NILOREA_HEX_HEADER */
unsigned char * n_hex_decode(const char *hex, size_t *out_len)
decode a hex string (ASCII whitespace between digits is ignored) into a freshly allocated,...
Definition n_hex.c:71
size_t n_hex_encode_to(char *out, size_t out_size, const unsigned char *data, size_t len)
encode len bytes of data as lowercase hex into the caller-provided buffer out (needs out_size >= 2*le...
Definition n_hex.c:117
int n_hex_decode_to(unsigned char *out, size_t out_size, const char *hex, size_t nbytes)
decode exactly nbytes bytes from the first 2*nbytes hex digits of hex (case-insensitive,...
Definition n_hex.c:141
N_STR * n_hex_encode(const unsigned char *data, size_t len)
encode len bytes of data as a lowercase hex N_STR (2*len characters); free with free_nstr.
Definition n_hex.c:48
A box including a string and his lenght.
Definition n_str.h:61
N_STR and string function declaration.