oath_base32_decode(3)
π oath_base32_decode β like, the liboath decoder, bestie
okay so this is a page from liboath (yes, that liboath) and it's all about oath_base32_decode, an API function. buckle up, it's actually so straightforward π
β¨ SYNOPSIS β¨
#include <oath.h>
int oath_base32_decode(const char * in, size_t inlen, char ** out,
size_t * outlen);
that's the whole signature, no cap. four arguments, one int back. let's get into it π¦
πΈ ARGUMENTS πΈ
const char * inβ the input string holding your base32 encoded data, and it'sinlenbytes long. that's it, that's the vibe.size_t inlenβ literally just the length of that input base32 stringin. the count. the number. πchar ** outβ a pointer to the output variable that'll hold the binary data of lengthoutlenβ¦ or you can passNULLif you're feeling mysterious. πsize_t * outlenβ a pointer to the output variable holding the length ofout. also allowed to beNULL. choose your own adventure β¨
π DESCRIPTION π
so the whole gig: it decodes a base32 encoded string into binary data. that's the function. iconic behaviour, honestly π
space characters? ignored. not a problem. and pad characters are added if needed β so if your input is missing its padding, the function just handles it for you, no drama π§
but non-base32 data? not ignored. not ignored, bestie. that's a hard no β it'll lead to an OATH_INVALID_BASE32 error. so keep your input clean or face the consequences π
the in parameter should contain inlen bytes of base32 encoded data. the function allocates a new string in *out to hold the decoded data, and sets *outlen to the length of the data. cute, right? it does the malloc-ing for you π«Ά
now the fun edge cases:
- if
outisNULL, then*outlenwill be set to what would have been the length of*outon successful encoding. so you can like, peek at the size first π - if you the caller are not interested in knowing the length of the output data
out, thenoutlenmay be set toNULL. no pressure. - and yes β it is permitted, but useless, to have both
outandoutlenNULL. you can. it just does nothing for you. it's giving "why are you here" energy π
π₯ RETURNS π₯
OATH_OK(which is zero) on success βOATH_INVALID_BASE32if the input contains non-base32 characters π«OATH_MALLOC_ERRORon memory allocation errors π
that's the whole return menu, fr fr.
π SINCE π
1.12.0 β been around a minute, lowkey a classic π
π REPORTING BUGS π
found a bug? report it to <oath-toolkit-help@nongnu.org> β they wanna hear it, no cap.
- liboath home page: https://oath-toolkit.codeberg.page/
- general help using GNU software: http://www.gnu.org/gethelp/
π COPYRIGHT π
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 β that's a very generous license π
and that's the page!! this beauty shipped as part of liboath version 2.6.15, manual page oath_base32_decode(3) β go decode something cute, bestie π
β¨π¦
π¦ where this page comes from
- arch rolling: oath-toolkit 2.6.15-1 Β· GPL-3.0-or-later
- nixpkgs unstable: oath-toolkit 2.6.15
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms