ZMQ_Z85_ENCODE(3)

✨ NAME ✨

okay so bestie, welcome to the zmq_z85_encode page πŸ’– this is the one from the 0MQ Manual, and it does exactly one iconic thing: it takes a binary key and turns it into Z85 printable text. slay.


🌸 SYNOPSIS 🌸

char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);

πŸ’… DESCRIPTION πŸ’…

so what does zmq_z85_encode() actually do?? it shall encode the binary block you hand it β€” that's the one specified by data and size β€” into a string, and it drops that string into dest. main character behaviour, honestly.

two things you literally cannot skip, no cap:

  • the size of the binary block must be divisible by 4. that's not a suggestion, that's the vibe check 🚨
  • dest must have sufficient space for size * 1.25 plus 1 for a null terminator.

and for the math girlies: a 32-byte CURVE key gets encoded as 40 ASCII characters plus a null terminator. that's the glow-up πŸ¦‹

the encoding shall follow the ZMQ RFC 32 specification. periodt.


πŸ”₯ RETURN VALUE πŸ”₯

zmq_z85_encode() shall return dest if it's successful ✨ else it shall return NULL. it's giving "either thriving or nothing at all" 😭


πŸŽ€ EXAMPLE πŸŽ€

encoding a CURVE key, bestie:

#include <sodium.h>
uint8_t public_key [32];
uint8_t secret_key [32];
int rc = crypto_box_keypair (public_key, secret_key);
assert (rc == 0);
char encoded [41];
zmq_z85_encode (encoded, public_key, 32);
puts (encoded);

note the char encoded [41] β€” 40 characters plus room for the null terminator, exactly like we said πŸ‘‘ she's prepared.


πŸ‘€ SEE ALSO πŸ‘€

go read those too, iykyk πŸ’œ


🌈 AUTHORS 🌈

this page was written by the 0MQ community. if you wanna make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. community effort fr fr, we love to see it 🫢


okay and that's the whole page, bestie!! this was the 0MQ 4.3.5 version, dated 10/09/2023, from the ZMQ_Z85_ENCODE(3) page itself πŸ’– go forth and encode responsibly, mwah πŸ˜˜πŸ’…

πŸ“¦ where this page comes from