NE_MKNONCE(3)

πŸ“¦
version 0.37.1 Β· 3 versions
, in epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ NAME ✨

ne_mknonce β€” bestie, this one generates a nonce πŸ’– (that's the neon API reference page NE_MKNONCE(3), in case you were wondering)


🌸 SYNOPSIS 🌸

#include <ne_string.h>

int ne_mknonce(unsigned char *nonce, size_t len, unsigned int flags);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so ne_mknonce fills up the buffer that nonce points at with len bytes of random data β€” and the whole point of that data is that it's suitable for use as a nonce ✨ no cap.

the value of len has to be greater than zero and no greater than 256. those are the rules, periodt πŸ™…β€β™€οΈ

the flags parameter is reserved for future use and must be set to zero. literally just pass 0 and move on πŸ’…

and here's the part where the vibes get real: the caller is responsible for making sure the buffer that nonce points at is at least len bytes big. that's on you, bestie, not on the function 🫢


πŸ‘‘ RETURN VALUE πŸ‘‘

ne_mknonce returns zero on success πŸŽ€

on error, it returns a non-zero errno value that tells you what went wrong β€” and heads up, the buffer contents are undefined in that case. like, don't trust what's in there. it's giving chaos πŸ’€


πŸ’œ EXAMPLE πŸ’œ

here's the iconic little demo: it generates a 16-byte nonce and encodes it as a hexadecimal string 🧚

unsigned char buf[16];
unsigned char hex[33];
int i, err;

err = ne_mknonce(buf, sizeof buf, 0);
if (err) {
    fprintf(stderr, "ne_mknonce failed: %s\n", strerror(err));
    return -1;
}

for (i = 0; i < 16; i++)
    sprintf(hex + 2 * i, "%02x", buf[i]);
hex[32] = '\0';

🌈 HISTORY 🌈

ne_mknonce is available in neon 0.37.0 and later ⭐ so if you're on something older… no she's not there yet, sorry 😭


Copyright Β© 2001-2026 Joe Orton πŸ’–


and that's the whole page, bestie!! this was the neon 0.37.1 manual, dated 15 March 2026, and you just read NE_MKNONCE(3) β€” slay, go make some nonces πŸŽ€βœ¨

πŸ“¦ where this page comes from