libwget-base64(3)
π libwget-base64 β the base64 bestie page π
okay so this is a page from the Library Functions Manual (that's the libwget-base64(3) vibe, iykyk) and it's literally all about the base64 functions. welcome to the group chat π«Ά
β¨ NAME β¨
libwget-base64 β Base64 functions π
πΈ SYNOPSIS πΈ
π Macros
#define WGET_BASE64_URLENCODE 1
π¦ Functions
bool wget_base64_is_string (const char *src)
size_t wget_base64_decode (char *dst, const char *src, size_t n)
char * wget_base64_decode_alloc (const char *src, size_t n, size_t *outlen)
size_t wget_base64_encode (char *dst, const char *src, size_t n)
size_t wget_base64_urlencode (char *dst, const char *src, size_t n)
char * wget_base64_encode_alloc (const char *src, size_t n)
char * wget_base64_encode_vprintf_alloc (const char *fmt, va_list args)
char * wget_base64_encode_printf_alloc (const char *fmt,...)
size_t wget_base64_get_decoded_length (size_t len)
size_t wget_base64_get_encoded_length (size_t len)
π DETAILED DESCRIPTION π
This is a collection of base64 encoding/decoding functions used in Wget2. like, the whole little base64 squad that Wget2 calls when it needs to turn bytes into that alphabet soup πβ¨
π FUNCTION DOCUMENTATION π
π bool wget_base64_is_string (const char * src)
Parameters
srcβ String to be checked
Returns
1 if src is a base64 string, 0 otherwise
Checks whether src is a base64 string. Returns 0 if src is NULL.
so basically a vibe check for strings β¨ null pointer? not it, bestie, that's a 0.
π size_t wget_base64_decode (char * dst, const char * src, size_t n)
Parameters
dstβ Output buffersrcβ Base64 string to be decodednβ Length ofsrc
Returns
Number of bytes written into dst
Decodes n bytes of the base64 string src. The decoded bytes are written into dst and are 0-terminated.
The size of dst has to be at minimum ((n + 3) / 4) * 3 + 1 bytes.
bestie, please size your buffer right, that formula is not a suggestion π
π char * wget_base64_decode_alloc (const char * src, size_t n, size_t * outlen)
Parameters
srcβ Base64 string to be decodednβ Length ofsrcoutlenβ Length of returned string, may beNULL.
Returns
Decoded bytes, zero terminated. Returns NULL if memory allocation failed.
Decodes n bytes of the base64 string src. The decoded bytes are returned in an allocated buffer.
You should free() the returned string when not needed any more.
this one hands you a fresh allocated buffer β main character energy β but you own it now, so free() it or it's a leak, no cap π«
π size_t wget_base64_encode (char * dst, const char * src, size_t n)
Parameters
dstβ Base64 output stringsrcβ Input buffernβ Number of bytes to be encoded
Returns
Length of output string dst
Encodes n bytes from src into a base64 string. The encoded string is written into dst (0-terminated).
The length of dst has to be at minimum ((n + 2) / 3) * 4 + 1 bytes.
π size_t wget_base64_urlencode (char * dst, const char * src, size_t n)
Parameters
dstβ Base64 output string (URL and filename safe)srcβ Input buffernβ Number of bytes to be encoded
Returns
Length of output string dst
Encodes n bytes from src into a base64 URL and filename safe string (see RFC 4648, 5.). The encoded string is written into dst (0-terminated).
The length of dst has to be at minimum ((n + 2) / 3) * 4 + 1 bytes.
same energy as the regular encode but it's the URL-and-filename-safe flavor π¦ (RFC 4648, 5., if you wanna read the lore)
π char * wget_base64_encode_alloc (const char * src, size_t n)
Parameters
srcβ Input buffernβ Number of bytes to be encoded
Returns
Base64 encoded string or NULL if memory allocation failed
Encodes n bytes from input buffer src. The encoded string is returned in an allocated buffer.
You should free() the returned string when not needed any more.
π char * wget_base64_encode_vprintf_alloc (const char * fmt, va_list args)
Parameters
fmtβ Printf-like format stringargsβ Argument list
Returns
Base64 encoded string
Encodes the string constructed by fmt and args. The encoded string is returned in an allocated buffer.
You should free() the returned string when not needed any more.
it builds the string from your printf-style format first, then base64s it. two-step slay π
π char * wget_base64_encode_printf_alloc (const char * fmt, ...)
Parameters
fmtβ Printf-like format string...β Argument list
Returns
Base64 encoded string
Encodes the string constructed by fmt and the arguments. The encoded string is returned in an allocated buffer.
You should free() the returned string when not needed any more.
π size_t wget_base64_get_decoded_length (size_t len)
Parameters
lenβ Length of base64 sequence
Returns
Number of decoded bytes plus one (for 0-byte termination)
Calculate the number of bytes needed for decoding a base64 sequence with length len.
use this before you malloc so you don't have to guess, fr fr π§
π size_t wget_base64_get_encoded_length (size_t len)
Parameters
lenβ Number of (un-encoded) bytes
Returns
Length of base64 encoding plus one (for 0-byte termination)
Calculate the number of bytes needed for base64 encoding a byte sequence with length len, including the padding and 0-termination bytes.
π AUTHOR π
Generated automatically by Doxygen for wget2 from the source code. π€β¨
and that's the whole page, bestie β it's giving wget2, Version 2.3.0, straight from the libwget-base64(3) manual, and honestly? iconic. go forth and base64 responsibly πππ¦
π¦ where this page comes from
- fedora 43: wget2-devel 2.3.0-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 43: wget2-devel 2.3.0-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 44: wget2-devel 2.3.0-1.fc44
- fedora 44: wget2-devel 2.3.0-1.fc44
- fedora 44: wget2-devel 2.3.0-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 44: wget2-devel 2.3.0-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms