The OpenD Programming Language

genRandomBlocking

Fills a buffer with random data. If not enough entropy has been gathered, it will block.

Note that on Mac OS X this method will never block.

  1. alias genRandomBlocking = mir_random_genRandomBlocking
  2. ptrdiff_t genRandomBlocking(ubyte[] buffer)
    @nogc nothrow @trusted
    ptrdiff_t
    genRandomBlocking
    ()
    (
    scope ubyte[] buffer
    )

Return Value

Type: ptrdiff_t

A non-zero integer if an error occurred.

Examples

ubyte[] buf = new ubyte[10];
genRandomBlocking(buf);

int sum;
foreach (b; buf)
    sum += b;

assert(sum > 0, "Only zero points generated");

Meta