b64.h(3)

📦
version 2.2.0 · 2 versions
, in fedora 44

👑 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 🌈

  1. 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: 000000 becomes the character 'A', ..., and 111111 becomes the character '/'. ✨
  2. 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.
  3. More precisely: if the block gets padded with 8 zero bits, then the first 18 = 6 * 3 bits of the block get encoded (16 meaningful bits plus 2 appended zeros). But if the block gets padded with 16 zero bits, then the first 12 = 6 * 2 bits get encoded (8 meaningful bits plus 4 zeros). 💅
  4. 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 buffers dest and src do 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 alphabet enc_table;
  • if the last block of the string looks like abc=, then in the 6-bit group corresponding to the character c, 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 character b, 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 (Предусловие) 👑 If dest != 0, then the buffer [count]dest is correct and its size is sufficient to hold the decoded data. The buffers dest and src do 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