public virtual char[] GenerateBitsAsCharsWithPeriodCheck(int length, Lfsr seed)
        {
            uint counter         = 0;
            uint period          = 0;
            bool periodFound     = false;
            var  initialRegister = new BitArray(seed.Register);

            char[] result = new char[length];

            for (int i = 0; i < length; i++)
            {
                result[i] = SeriesConverter.BoolToChar(GenerateOneBit());
                counter++;

                if (CompareBitArrays(initialRegister, this.Registers[0].Register))
                {
                    period      = counter;
                    counter     = 0;
                    periodFound = true;
                }
            }
            if (periodFound)
            {
                this.Period = period;
            }
            else
            {
                this.Period = counter;
            }

            return(result);
        }
Exemple #2
0
        public A5_1Generator()
        {
            Registers = new Lfsr[3];

            Registers[0] = new Lfsr(19, true);
            Registers[1] = new Lfsr(22, true);
            Registers[2] = new Lfsr(23, true);
        }
 public StopAndGoGenerator()
 {
     Lfsr[] lfsrs = new Lfsr[NumberOfRegisters];
     for (int i = 0; i < lfsrs.Length; i++)
     {
         lfsrs[i] = new Lfsr();
     }
     Registers = lfsrs;
 }
 public ShrinkingGenerator()
 {
     Lfsr[] lfsr = new Lfsr[2];
     for (int i = 0; i < lfsr.Length; i++)
     {
         lfsr[i] = new Lfsr();
     }
     Registers = lfsr;
 }
 //Generates registers with default length (8)
 public GeffesGenerator()
 {
     Lfsr[] lfsr = new Lfsr[3];
     for (int i = 0; i < lfsr.Length; i++)
     {
         lfsr[i] = new Lfsr();
     }
     Registers = lfsr;
 }
Exemple #6
0
        public CascadeGenerator(int numOfLfsr)
        {
            Lfsr[] lfsr = new Lfsr[numOfLfsr];
            for (int i = 0; i < lfsr.Length; i++)
            {
                lfsr[i] = new Lfsr();
            }

            Registers = lfsr;
        }
        public void ChangeRegister(Lfsr register, int registerIndex)
        {
            if (registerIndex > Registers.Length - 1)
            {
                throw new ArgumentException("Niepoprawny indeks rejestru!");
            }
            else
            {
                Registers[registerIndex] = register;
            }

            Registers[registerIndex].UpdateOutputBit();
        }
        //period check

        public virtual byte[] GenerateBytesWithPeriodCheck(int length, Lfsr seed)
        {
            uint counter         = 0;
            uint period          = 0;
            var  initialRegister = new BitArray(seed.Register);

            bool[] result = new bool[length * 8];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = GenerateOneBit();
                counter++;

                if (initialRegister.Equals(this.Registers[0]))
                {
                    period = counter;
                }
                this.Period = period;
            }


            return(SeriesConverter.BoolToByteArray(result));
        }
 public LfsrGenerator()
 {
     Registers = new Lfsr[1];
 }
 public SelfDecimationGenerator()
 {
     Registers = new Lfsr[1] {
         new Lfsr()
     };
 }
Exemple #11
0
 public SelfShrinkingGenerator()
 {
     Registers = new Lfsr[1] {
         new Lfsr()
     };
 }