b64.h(3)
👑 b64.h — base64 but make it a whole personality 👑
hiii bestie, this is b64.h(3) from the Library Functions Manual and it's literally the base64 page, we're doing this together, hold my hand 🫶
✨ NAME ✨
b64.h — base64 encoding, no cap 💅
🌸 SYNOPSIS 🌸
#include 'bee2/defs.h'
🎀 Functions (the whole cast, they're icons) 🎀
bool_t b64IsValid (const char *b64)— is this base64 string actually valid? vibe check 🔍void b64From (char *dest, const void *src, size_t count)— encode a memory buffer ✨void b64To (void *dest, size_t *count, const char *src)— decode a memory buffer 🦋
💖 DESCRIPTION (Подробное описание) 💖
okay so, it encodes memory buffers into base64 strings, following the rules of RFC 4848, periodt. A base64 string is a word in the alphabet b64_alphabet = {'A',...,'F','a',...,'f','0',...,'9','+','/'}, and it can get padded with one or two '=' characters, and its length is always a multiple of 4. always always. 🔥
🌈 the encoding rules, bestie, listen up 🌈
- The data being encoded gets split into blocks — triples of octets, aka 24-bit chunks. Every 24-chunk gets split into four 6-chunks. Every 6-chunk gets encoded by 1 character of
b64_alphabet:000000becomes the character'A', ..., and111111becomes the character'/'. ✨ - If the last data block is incomplete, it gets padded up to a full one with 8 or 16 zero bits, and then it's encoded by 3 or 2 characters of
b64_alphabet. - More precisely: if the block gets padded with 8 zero bits, then the first
18 = 6 * 3bits of the block get encoded (16 meaningful bits plus 2 appended zeros). But if the block gets padded with 16 zero bits, then the first12 = 6 * 2bits get encoded (8 meaningful bits plus 4 zeros). 💅 - The final code word gets padded with
'='characters until its length becomes a multiple of 4. If the last data block was full, no'='gets appended, nope. If the last block had 2 octets, then 1'='character gets appended; if it had 1 octet — then 2 characters. 😌
Precondition (Предусловие) 🫶 Every function, except possibly b64IsValid(), is passed valid strings and memory buffers. Like, that's on you, bestie.
🦋 FUNCTIONS (Функции) 🦋
🌟 void b64From (char * dest, const void * src, size_t count) 🌟
The buffer [count]src gets encoded into the base64 string [4 * ((count + 2) / 3) + 1]dest. slay ✨
Precondition (Предусловие) 💀 The buffersdestandsrcdo not overlap. not even a little.
🍓 Arguments (Аргументы) 🍓
- dest — destination string 💖
- src — source memory 🌸
- count — number of octets 👑
🔍 bool_t b64IsValid (const char * b64) 🔍
It checks whether the base64 string b64 is valid. A string counts as valid if:
- its length is a multiple of 4;
- the string may end with 1 or 2
'='characters, and all the other characters belong to the alphabetenc_table; - if the last block of the string looks like
abc=, then in the 6-bit group corresponding to the characterc, the two low bits are zero; - if the last block of the string looks like
ab==, then in the 6-bit group corresponding to the characterb, the four low bits are zero.
🎀 Returns (Возвращает) 🎀
The validity flag. true or false, that's it, that's the tea ☕
💜 Regularity (Регулярность) 💜
The function is irregular (нерегулярна). so don't come for it, it's just built different.
🍓 Arguments (Аргументы) 🍓
- b64 — base64 string 💖
🌈 void b64To (void * dest, size_t * count, const char * src) 🌈
The base64 string src gets decoded into a string of octets [count?]dest. 🦋
Preconditions (Предусловие) 👑 Ifdest != 0, then the buffer[count]destis correct and its size is sufficient to hold the decoded data. The buffersdestandsrcdo not overlap.b64IsValid(src) == TRUE. like, actually true. fr fr.
⭐ Note (Прим.) ⭐
The decoded data will always fit into a buffer of 3 * strLen(src) / 4 octets. math said so, so it's true 💅
🍓 Arguments (Аргументы) 🍓
- dest — destination memory 💖
- count — size of
dest/ size of the decoded data 🌸 - src — source string 🎀
🌸 AUTHOR (Автор) 🌸
Automatically generated by Doxygen for the Bee2 Library from the source text. not me getting auto-generated 😭
and that's the whole page, bestie!! 💖✨🦋 this was Bee2 Library, and the timestamp on this masterpiece is Вс 25 Янв 2026 00:00:00 — you're welcome, go encode something cute 🎀👑💅
📦 where this page comes from
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms