oath_hex2bin(3)

πŸ’… oath_hex2bin(3) β€” like, the liboath glow-up page πŸŽ€

okay so bestie, you're looking at oath_hex2bin, a function from the liboath manual, section 3. that's the whole vibe. let's get into it ✨


🌸 SYNOPSIS 🌸

like, here's the whole thing, copy it exactly or it won't compile, no cap:

#include <oath.h>

int oath_hex2bin(const char * hexstr, char * binstr, size_t * binlen);

three arguments, one int back. she's simple, she's iconic. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • const char * hexstr β€” the input string, and it's carrying hex data. that's her whole personality. πŸ“
  • char * binstr β€” the output string that holds the binary data. or NULL! she can absolutely be NULL, it's giving mysterious. πŸ™ˆ
  • size_t * binlen β€” an output variable holding the needed length of binstr. so she tells you how much room you actually need. queen behavior. πŸ‘‘

✨ DESCRIPTION ✨

so the entire job is: convert a string with hex data into binary data. literally that's it. hex in, binary out. 🧚

now listen, and this is the important part β€” non-hexadecimal data are not ignored. she does not let that slide. instead they will lead to an OATH_INVALID_HEX error. no silent skipping, no "close enough", she will absolutely call you out. πŸ’€

here's the part where binlen is doing main character energy:

  • if binstr is NULL, then binlen will be populated with the necessary length. so you can ask "how big does this need to be" before you commit. obsessed. 🫢
  • if the binstr buffer is too small, OATH_TOO_SMALL_BUFFER is returned, and binlen will contain the necessary length. she's not gonna write half and leave you guessing β€” she tells you the size you need. slay. 🌈

πŸ”₯ RETURNS πŸ”₯

on success, OATH_OK (zero) is returned. otherwise an error code is returned. that's the whole contract, bestie. zero = we ate. nonzero = read the code and cry a little. 😭


πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? don't suffer in silence, tell the group chat:

report bugs to <oath-toolkit-help@nongnu.org>.

also for your bookmarks:


Copyright Β© 2009-2026 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. so like, go forth and share it, just keep the receipts. πŸ’–


and that's the page!! this was oath_hex2bin(3) from liboath, version 2.6.15 β€” periodt. β­πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from