gnutls_pem_base64_encode2(3)

πŸ’– gnutls_pem_base64_encode2 πŸ’–

okay bestie, sit down, hydrate, and let me tell you about this little function from the GnuTLS manual. yes it's a <pink>3</pink> page, yes it's C, no you don't have to be scared. it's giving "one job, does it well" energy and honestly? we love that for it.


✨ NAME ✨

gnutls_pem_base64_encode2 β€” an API function πŸŽ€ (yes that's literally the whole name section, she's lowkey mysterious like that)


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

int gnutls_pem_base64_encode2(const char * header, const gnutls_datum_t
* data, gnutls_datum_t * result);

like, look at her. three arguments, one int coming back. no drama. πŸ‘‘


πŸ¦‹ ARGUMENTS πŸ¦‹

  • const char * header β€” the message you wanna stick up in the encoded header. and guess what, bestie: it may be NULL πŸ’… so don't stress if you've got nothing to say up top.
  • const gnutls_datum_t * data β€” the raw data. the actual contents. the main character of this whole situation 🫢
  • gnutls_datum_t * result β€” this is where the freshly allocated, encoded data is gonna land. she's a pointer, she's getting filled in, she's that girl.

πŸ’œ DESCRIPTION πŸ’œ

so what does she do? she takes the data you hand her and converts it into printable data using base64 encoding. and base64 is literally the encoding PEM messages run on, so if you're doing PEM stuff, you're in the right place, iykyk 🌈

the key thing, the one you must not forget: this function allocates the memory it needs to hold the encoded data. she's not borrowing your buffer, she's not asking you to guess a size, she's just... allocating. iconic behaviour, honestly.

✨ because she allocates, you should use gnutls_free() to free the returned data. do NOT forget this. do not pass go. do not just leak it into the void, bestie, that's not the vibe 😭

and here's a lil lore drop for the historians in the chat: prior to GnuTLS 3.4.0, this exact function was hanging out under the name gnutls_pem_base64_encode_alloc(). there is a compatibility macro pointing to this function, so old code still finds her. she just rebranded. slay πŸ’…βœ¨


⭐ RETURNS ⭐

if everything goes right? you get GNUTLS_E_SUCCESS and that value is 0 πŸŽ‰ otherwise you get an error code back. that's it. that's the return section. no cap.


🌟 SINCE 🌟

3.4.0 β€” she's been here since 3.4.0, and she's been booked and busy ever since πŸ’–


πŸ› REPORTING BUGS πŸ›

found a bug? don't be shy, tell the devs:

fr fr, they wanna hear it πŸ™ˆ


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. (that's the whole legal vibe, and honestly, very generous of them 🫢)


🌈 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, go visit:

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

like, go read it. it's right there. it's free. it's iconic πŸ“šβœ¨


okay that's the whole page, you made it, I'm so proud of you πŸ₯ΉπŸ’– this was the gnutls manual, page gnutls_pem_base64_encode2(3), straight out of GnuTLS 3.8.13 β€” thanks for reading, go call gnutls_free(), and drink some water. bye bestie!! πŸ’…πŸŽ€πŸ¦‹πŸŒΈβ­

πŸ“¦ where this page comes from