Line data Source code
1 1 : import { nativeMath } from "../engine/nativeMath.ts"; 2 : import { Engine } from "../types.ts"; 3 : 4 : /** 5 : * Returns an array of random int32 values, based on current time 6 : * and a random number engine 7 : * 8 : * @param engine an Engine to pull random values from, default `nativeMath` 9 : * @param length the length of the Array, minimum 1, default 16 10 : */ 11 0 : export function createEntropy( 12 0 : engine: Engine = nativeMath, 13 0 : length: number = 16 14 : ): number[] { 15 0 : const array: number[] = []; 16 0 : array.push(new Date().getTime() | 0); 17 0 : for (let i = 1; i < length; ++i) { 18 0 : array[i] = engine.next() | 0; 19 0 : } 20 0 : return array; 21 0 : }