summaryrefslogtreecommitdiff
path: root/mt19937_mtrng_s3.c
diff options
context:
space:
mode:
Diffstat (limited to 'mt19937_mtrng_s3.c')
-rw-r--r--mt19937_mtrng_s3.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/mt19937_mtrng_s3.c b/mt19937_mtrng_s3.c
new file mode 100644
index 0000000..b74c0fa
--- /dev/null
+++ b/mt19937_mtrng_s3.c
@@ -0,0 +1,20 @@
+// https://cryptopals.com/sets/3/challenges/21
+#include "util/mersenne_twister.h"
+#include <stdio.h>
+
+int main() {
+ seed(0);
+ // extra basic statistical test; checks whether
+ // lowest significant bit is random enough :^)
+ //(borrowed from testU01)
+ int even = 0, odd = 0;
+ for (int i = 0; i < 10000; i++) {
+ uint32_t r = extract();
+ if (r % 2 == 0)
+ even++;
+ else
+ odd++;
+ }
+ printf("even: %d, odd: %d\n", even, odd);
+ return 0;
+}