{"unit":"https://translate-dev.freebsd.org/api/units/157126/?format=json","component":"https://translate-dev.freebsd.org/api/components/freebsd-doc/articles_ipsec-must/?format=json","translation":"https://translate-dev.freebsd.org/api/translations/freebsd-doc/articles_ipsec-must/fa/?format=json","user":"https://translate-dev.freebsd.org/api/users/kouhi/?format=json","author":"https://translate-dev.freebsd.org/api/users/kouhi/?format=json","timestamp":"2020-04-01T10:49:55.193268Z","action":5,"target":"/*\n  ULISCAN.c   ---blocksize of 8\n\n  1 Oct 98\n  1 Dec 98\n  21 Dec 98       uliscan.c derived from ueli8.c\n\n  This version has // comments removed for Sun cc\n\n  This implements Ueli M Maurer's \"Universal Statistical Test for Random\n  Bit Generators\" using L=8\n\n  Accepts a filename on the command line; writes its results, with other\n  info, to stdout.\n\n  Handles input file exhaustion gracefully.\n\n  Ref: J. Cryptology v 5 no 2, 1992 pp 89-105\n  also on the web somewhere, which is where I found it.\n\n  -David Honig\n  honig@sprynet.com\n\n  Usage:\n  ULISCAN filename\n  outputs to stdout\n*/\n\n#define L 8\n#define V (1&lt;&lt;L)\n#define Q (10*V)\n#define K (100   *Q)\n#define MAXSAMP (Q + K)\n\n#include &lt;stdio.h&gt;\n#include &lt;math.h&gt;\n\nint main(argc, argv)\nint argc;\nchar **argv;\n{\n  FILE *fptr;\n  int i,j;\n  int b, c;\n  int table[V];\n  double sum = 0.0;\n  int iproduct = 1;\n  int run;\n\n  extern double   log(/* double x */);\n\n  printf(\"Uliscan 21 Dec 98 \\nL=%d %d %d \\n\", L, V, MAXSAMP);\n\n  if (argc &lt; 2) {\n    printf(\"Usage: Uliscan filename\\n\");\n    exit(-1);\n  } else {\n    printf(\"Measuring file %s\\n\", argv[1]);\n  }\n\n  fptr = fopen(argv[1],\"rb\");\n\n  if (fptr == NULL) {\n    printf(\"Can't find %s\\n\", argv[1]);\n    exit(-1);\n  }\n\n  for (i = 0; i &lt; V; i++) {\n    table[i] = 0;\n  }\n\n  for (i = 0; i &lt; Q; i++) {\n    b = fgetc(fptr);\n    table[b] = i;\n  }\n\n  printf(\"Init done\\n\");\n\n  printf(\"Expected value for L=8 is 7.1836656\\n\");\n\n  run = 1;\n\n  while (run) {\n    sum = 0.0;\n    iproduct = 1;\n\n    if (run)\n      for (i = Q; run &amp;&amp; i &lt; Q + K; i++) {\n        j = i;\n        b = fgetc(fptr);\n\n        if (b &lt; 0)\n          run = 0;\n\n        if (run) {\n          if (table[b] &gt; j)\n            j += K;\n\n          sum += log((double)(j-table[b]));\n\n          table[b] = i;\n        }\n      }\n\n    if (!run)\n      printf(\"Premature end of file; read %d blocks.\\n\", i - Q);\n\n    sum = (sum/((double)(i - Q))) /  log(2.0);\n    printf(\"%4.4f \", sum);\n\n    for (i = 0; i &lt; (int)(sum*8.0 + 0.50); i++)\n      printf(\"-\");\n\n    printf(\"\\n\");\n\n    /* refill initial table */\n    if (0) {\n      for (i = 0; i &lt; Q; i++) {\n        b = fgetc(fptr);\n        if (b &lt; 0) {\n          run = 0;\n        } else {\n          table[b] = i;\n        }\n      }\n    }\n  }\n}","id":64030,"action_name":"New translation","url":"https://translate-dev.freebsd.org/api/changes/64030/?format=json"}