gnutls_pem_base64_encode(3)

πŸ’… gnutls_pem_base64_encode β€” the glow-up page ✨

okay bestie, so this is a page from the gnutls manual (the 3.8.13 era, iykyk). it's literally called gnutls_pem_base64_encode and it's about to make your raw bytes look cute and printable. let's go 🫢


🌸 NAME 🌸

gnutls_pem_base64_encode β€” an API function, bestie. that's the whole name. short, sweet, iconic. πŸ‘‘


✨ SYNOPSIS ✨

#include <gnutls/gnutls.h>

int gnutls_pem_base64_encode(const char * msg, const gnutls_datum_t *
data, char * result, size_t * result_size);

no cap, that's the whole signature. copy it exactly, don't freestyle it. πŸ’€


πŸŽ€ ARGUMENTS πŸŽ€

  • const char * msg β€” this is a message that gets put up in the header, like a little caption on your post. and yes, it may be NULL, so you're allowed to be mysterious and post with no caption. πŸ™ˆ
  • const gnutls_datum_t * data β€” this is where the raw data lives. the un-glammed, un-encoded, pre-glow-up version. literally the before picture.
  • char * result β€” the spot where the base64 data is gonna get copied. this is the after picture. πŸ’–
  • size_t * result_size β€” holds the size of the result. it knows how big the whole thing is. main character energy.

πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works is: this function converts the given data into printable data using the base64 encoding. and bestie, that's not just any encoding β€” that's the exact encoding used in PEM messages. it's giving certified, standard, official. πŸ”₯

the output string will be null terminated, which is the polite thing to do. but plot twist: the output size will not include that terminating null. so don't be out here counting the null and getting confused. the null is there, it's just not invited to the size party. ✨


πŸ‘‘ RETURNS πŸ‘‘

on success, GNUTLS_E_SUCCESS (0) is returned. slay. πŸ’…

but if the buffer you gave it is not long enough, you get GNUTLS_E_SHORT_MEMORY_BUFFER back. and, well, the original also says or 0 on success β€” yeah, it says success twice, and honestly? we respect the confidence. it's literally the same thing stated with full chest. periodt. πŸ’€


πŸ› REPORTING BUGS πŸ›

found a bug? don't suffer in silence, bestie, that's not the vibe. report it to:

<bugs@gnutls.org>

and if you wanna check the whole operation out, the home page is:

https://www.gnutls.org


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

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. so yes, you may absolutely redistribute this, just keep the receipts. no erasing credits, that's not the move. 🫢


🌟 SEE ALSO 🌟

the full documentation for gnutls is maintained as a Texinfo manual. if the /usr/share/doc/gnutls/ directory does not contain the HTML form, then bestie, just go visit:

https://www.gnutls.org/manual/

and that's the whole page!! this one came from gnutls 3.8.13, dated the gnutls way, and it's genuinely so iconic that a function this small is this useful. encode responsibly, hydrate, and always null terminate your strings. mwah. πŸ’–πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from