41#ifdef HAVE_SYS_RANDOM_H
42#include <sys/random.h>
49static const unsigned char Base32[] =
"abcdefghijklmnopqrstuvwxyz234567";
73 rc = getrandom((
char *) buf + count, buflen - count, 0);
76 }
while (((rc >= 0) && (count < buflen)) || ((rc == -1) && (errno == EINTR)));
87 mutt_error(
_(
"open /dev/urandom: %s"), strerror(errno));
92 if (fread(buf, 1, buflen,
FpRandom) != buflen)
94 mutt_error(
_(
"read /dev/urandom: %s"), strerror(errno));
108 if (!buf || (buflen == 0))
111 uint8_t *p = (uint8_t *) buf;
115 for (
size_t pos = 0; pos < buflen; pos++)
116 p[pos] =
Base32[p[pos] % 32];
File management functions.
#define mutt_file_fopen(PATH, MODE)
void mutt_exit(int code)
Leave NeoMutt NOW.
static const unsigned char Base32[]
Base 32 alphabet.
uint64_t mutt_rand64(void)
Create a 64-bit random number.
static int mutt_randbuf(void *buf, size_t buflen)
Fill a buffer with randomness.
static FILE * FpRandom
FILE pointer of the random source.
void mutt_rand_base32(char *buf, size_t buflen)
Fill a buffer with a base32-encoded random string.
Random number/string functions.