oath_bin2hex(3)

✨ oath_bin2hex(3) ✨

okay bestie, welcome to liboath β€” this little cutie is oath_bin2hex, and it's literally the glow-up your binary data has been waiting for πŸ’…


🌸 NAME 🌸

oath_bin2hex β€” it's an API function, no cap, and it's here to serve 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <oath.h>

void oath_bin2hex(const char * binstr, size_t binlen, char * hexstr);

like, that's the whole vibe. short, iconic, to the point πŸ‘‘


πŸ¦‹ ARGUMENTS πŸ¦‹

  • const char * binstr β€” the input binary data. your raw, unedited self. we love her πŸ™ˆ
  • size_t binlen β€” the length of that input binary data binstr. you gotta tell her how much she's working with, fr fr
  • char * hexstr β€” the output string with hex data. ⚠️ and listen β€” she must have room for 2*binlen+1. not 2*binlen, not "eh, close enough." 2*binlen+1. the +1 is the NUL, she's important πŸ’€

πŸ’– DESCRIPTION πŸ’–

So what does she actually do? She converts binary data into a NUL-terminated string with hex data. that's it, that's the whole job, and she does it flawlessly ✨

the output hexstr is allocated by the caller β€” that's you, bestie, you're the main character here β€” and it must have room for at least 2*binlen+1. why? because you need space for the encoded data and the terminating NUL byte. the math is mathing, the vibes are immaculate πŸ’…

no cap: if you skimp on that buffer size, that's on you. the +1 is not decorative, she's load-bearing 😭

🌈 SINCE 🌈

1.12.0 β€” she's been around a minute. vintage, but make it fresh πŸŽ€


πŸ› REPORTING BUGS πŸ›

Found a bug? don't suffer in silence, bestie β€” report it to oath-toolkit-help@nongnu.org πŸ“§


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. slay, honestly β€” free to share, just keep the receipts 🫢


🌸 κ’°ΰ¦Œ sign-off ΰ»’κ’± 🌸

that was oath_bin2hex(3) from liboath, version 2.6.15 β€” go forth and hex-encode responsibly, bestie. you're gonna ate this πŸ’œβœ¨

⭐⭐⭐

πŸ“¦ where this page comes from