--- /dev/null
+CC=gcc
+CFLAGS=-std=c99 -Wall -Wextra
+
+all: exercise1b.c exercise1d.c
+ $(CC) $(CFLAGS) exercise1b.c -o exercise1b
+ $(CC) $(CFLAGS) exercise1d.c -o exercise1d
+
+clean:
+ $(RM) exercise1b exercise1d
--- /dev/null
+/dev/random generates random bytes from a 4096 bits entropy pool and will only
+use fresh entropy.
+
+/dev/urandom generates random bytes from a 4096 bits entropy pool too but it
+reuses entropy while the entropy pool is filled. Because of the reuse
+/dev/urandom is much faster then /dev/random
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+ FILE *f = fopen("/dev/urandom", "r");
+ char c;
+ do {
+ c = fgetc(f);
+ printf("%i %u %x\n", c, c, c);
+ } while(c != 42);
+ if(f != stdin)
+ fclose(f);
+ return 0;
+}
--- /dev/null
+-82 4294967214 ffffffae
+91 91 5b
+-63 4294967233 ffffffc1
+-41 4294967255 ffffffd7
+-22 4294967274 ffffffea
+103 103 67
+-33 4294967263 ffffffdf
+-115 4294967181 ffffff8d
+-90 4294967206 ffffffa6
+108 108 6c
+60 60 3c
+-42 4294967254 ffffffd6
+-55 4294967241 ffffffc9
+-26 4294967270 ffffffe6
+25 25 19
+42 42 2a
--- /dev/null
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+ FILE *f = fopen("/dev/urandom", "r");
+ uint16_t c;
+ do {
+ c = fgetc(f)+fgetc(f)*256;
+ printf("%04x\n", c);
+ } while(c != 42);
+ if(f != stdin)
+ fclose(f);
+ return 0;
+}
--- /dev/null
+271325
+40516
+65532
+23964
+41888
+95550
+234585
+50847
+85879
+87536
--- /dev/null
+{ for ((i=0;i<10;i++)); do ./exercise1d | wc -l; done; } > exercise1d.txt