public virtual Sequence Generate(uint length) { var sequence = new Sequence(length); Generate(sequence); return sequence; }
public override void Generate(Sequence sequence) { var init = false; var lastDouble = new double(); for (var i = 0; i < sequence.Value.Length; i++) { var bits = new bool[8]; for (var j = 0; j < 8; j++) { if (!init) { init = true; var random = (new Random()).Next(0, P); lastDouble = Math.Pow(A, random) % P; } else { lastDouble = Math.Pow(A, lastDouble) % P; } if (lastDouble < (P - 1.0) / 2.0) { bits[j] = true; } else { bits[j] = false; } } ToByte(ref sequence.Value[i], bits); } }
public abstract void Generate(Sequence sequence);
public override void Generate(Sequence sequence) { _rngCryptoServiceProvider.GetBytes(sequence.Value); }