oath\_hex2bin(3) liboath oath\_hex2bin(3)

# [NAME](#NAME)

oath\_hex2bin - API function

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;oath.h&gt;**

**int oath\_hex2bin(const char * hexstr, char * binstr, size\_t * binlen);**

# [ARGUMENTS](#ARGUMENTS)

[const char * hexstr](#const)

input string with hex data

[char * binstr](#char)

output string that holds binary data, or NULL

[size\_t * binlen](#size_t)

output variable holding needed length of *binstr*

# [DESCRIPTION](#DESCRIPTION)

Convert string with hex data to binary data.

Non-hexadecimal data are not ignored but instead will lead to an **OATH\_INVALID\_HEX** error.

If *binstr* is NULL, then *binlen* will be populated with the necessary length. If the *binstr* buffer is too small, **OATH\_TOO\_SMALL\_BUFFER** is returned and *binlen* will contain the necessary length.

# [RETURNS](#RETURNS)

On success, **OATH\_OK** (zero) is returned, otherwise an error code is returned.

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;oath-toolkit-help@nongnu.org&gt;. liboath home page: https://www.nongnu.org/oath-toolkit/ General help using GNU software: http://www.gnu.org/gethelp/

# [COPYRIGHT](#COPYRIGHT)

Copyright © 2009-2020 Simon Josefsson.  
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

2.6.12-dirty liboath

---

Document: oath_hex2bin(3) from oath-toolkit 2.6.12-r13 (Chainguard OS)
Source: https://gitlab.com/oath-toolkit/oath-toolkit.git
