oath_base32_encode(3)

πŸ’… oath_base32_encode(3) β€” the liboath glow-up

okay so bestie, welcome to liboath and specifically to oath_base32_encode(3), which is genuinely one of those little API functions that just works and minds its own business. it's the base32 encoder. that's it. that's the vibe. ✨


🌸 NAME

oath_base32_encode β€” the API function that takes your raw binary data and serves it up as base32. she's an icon, she's a legend, and she is the moment πŸ‘‘


πŸ¦‹ SYNOPSIS

#include <oath.h>

int oath_base32_encode(const char * in, size_t inlen, char ** out,
size_t * outlen);

like, that's the whole thing. one include, one call, and it's giving "i have my life together" πŸŽ€


πŸ“ ARGUMENTS

  • const char * in β€” your input string, and it's carrying binary data of length inlen. yes bestie, actual bytes, not necessarily cute printable text πŸ™ˆ
  • size_t inlen β€” the length of the input data in. the number of bytes. that's how many bytes of in she's gonna look at πŸ’«
  • char ** out β€” a pointer to a newly allocated output string of length outlen, or NULL. she'll allocate it for you, no cap 🫢
  • size_t * outlen β€” a pointer to the output variable that holds the length of out, or NULL. also totally allowed to be NULL, see below πŸ”₯

πŸ’– DESCRIPTION

Encode binary data into a string with base32 data. that's the whole job. short king energy but make it cryptography-adjacent.

the in parameter should contain inlen bytes of data to encode. so like, you hand her bytes and you tell her exactly how many bytes, and she does not go snooping past that, okay? boundaries. πŸ’…

the function allocates a new string in *out to hold the encoded data, and sets *outlen to the length of that data. and listen β€” the output string *out is zero-terminated (ASCII NUL), but the NUL is not counted in *outlen. the NUL is like, there for the vibes. it doesn't count toward the length. don't @ me, that's just how it is ⭐

if out is NULL, then *outlen will be set to what would have been the length of *out on successful encoding. so it's a whole "just tell me how big it'd be" situation. very demure, very mindful 🌸

if the caller is not interested in knowing the length of the output data out, then outlen may be set to NULL. she's flexible like that πŸ¦‹

and yes β€” it is permitted but useless to have both out and outlen NULL. technically legal. completely pointless. it's giving "showing up to the party and standing in the hallway" 😭

πŸ‘‘ RETURNS

on success OATH_OK (zero) is returned. slay. the zero is the good one, remember that okay?

  • OATH_BASE32_OVERFLOW β€” returned if the output would be too large to store 😭
  • OATH_MALLOC_ERROR β€” returned on memory allocation errors πŸ’€

so, like, three possible outcomes and two of them are bad news. check your return values bestie, it's literally free πŸ”₯


⭐ SINCE

1.12.0 β€” so she's been serving since 1.12.0, an elder icon, respect her πŸŽ€


🌈 REPORTING BUGS

Report bugs to <oath-toolkit-help@nongnu.org>. yes, actually email them, don't just complain in the group chat πŸ’œ


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.

like, keep the notice, that's the whole ask. iconic of them to make it that easy 🫢


🧚 sign-off

that's the page babes! you've just read oath_base32_encode(3) from liboath version 2.6.15 β€” go forth, encode your bytes, check your OATH_OK, and remember: zero is the good one πŸ’…βœ¨

πŸ“¦ where this page comes from