blob: 5a07110659492ad545b6e147ac67e9da1d25cc26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include "random.h"
#include "random-glib.h"
NiceRNG *
nice_rng_new (void)
{
NiceRNG *rng;
rng = nice_rng_glib_new ();
rng->seed (rng, 0);
return rng;
}
void
nice_rng_free (NiceRNG *rng)
{
rng->free (rng);
}
void
nice_rng_generate_bytes (NiceRNG *rng, guint len, gchar *buf)
{
rng->generate_bytes (rng, len, buf);
}
guint
nice_rng_generate_int (NiceRNG *rng, guint low, guint high)
{
return rng->generate_int (rng, low, high);
}
void
nice_rng_generate_bytes_print (NiceRNG *rng, guint len, gchar *buf)
{
guint i;
gchar *chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"01234567890";
for (i = 0; i < len; i++)
buf[i] = chars[nice_rng_generate_int (rng, 0, 62)];
}
|