summaryrefslogtreecommitdiff
path: root/mt19937_mtrng_s3.c
blob: b74c0fabadab741eb8864f092c727f81410bc166 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
}