1 /// Helpers used in tests and examples. 2 module chunker.internal.helpers; 3 4 package(chunker): 5 6 private import chunker.internal.gorng; 7 8 ubyte[] getRandom(int seed, int count) 9 { 10 import std.random : Random, uniform; 11 auto buf = new ubyte[count]; 12 13 RNGSource rnd; 14 .seed(&rnd, seed); 15 for (auto i = 0; i < count; i += 4) 16 { 17 auto r = int63(&rnd) >> 31; 18 buf[i] = cast(ubyte)(r); 19 buf[i+1] = cast(ubyte)(r >> 8); 20 buf[i+2] = cast(ubyte)(r >> 16); 21 buf[i+3] = cast(ubyte)(r >> 24); 22 } 23 24 return buf; 25 }