NE_MKNONCE(3)
β¨ 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 π
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
- epel 10: neon-devel 0.37.1-4.el10_3 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 43: neon-devel 0.37.1-1.fc43 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 43: neon-devel 0.37.1-1.fc43 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 44: neon-devel 0.37.1-1.fc44 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 44: neon-devel 0.37.1-1.fc44 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- nixos 26.05: neon 0.37.1
- nixpkgs unstable: neon 0.37.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms