Exemplo n.º 1
0
 public SaltyRandomGenerator(SaltyRandomGenerator clone)
 {
     this.entropy    = clone.entropy;
     this.bits_avail = clone.bits_avail;
     this.bits_used  = clone.bits_used;
     this.getsalt    = clone.getsalt;
 }
Exemplo n.º 2
0
        public static void Test()
        {
            SaltyRandomGenerator srg = new SaltyRandomGenerator();

            srg.getsalt += srg_getsalt;
            BitCollector collector = new BitCollector(512);
            int          bits;
            int          n;

            for (bits = 1; bits < 28; bits++)
            {
                srg.Reset();
                collector.Clear();
                for (n = 0; n < (512 - bits); n += bits)
                {
                    int value = srg.GetEntropy(bits, false);
                    collector.AddBits((uint)value, bits);
                }
                {
                    int final_value = srg.GetEntropy(512 - n, false);
                    collector.AddBits((uint)final_value, 512 - n);
                }
                byte[] one = srg.entropy;
                byte[] two = collector.buffer;
                for (n = 0; n < 512 / 8; n++)
                {
                    if (one[n] != two[n])
                    {
                        Console.WriteLine("Byte " + n + " differed " + one[n].ToString("x") + " " + two[n].ToString("x"));
                    }
                }
            }

            for (bits = 1; bits < 28; bits++)
            {
                srg.Reset();
                collector.Clear();
                for (n = 0; n < (512 - bits); n += bits)
                {
                    int value = srg.GetEntropy(bits, true);
                    collector.AddBits((uint)value, bits);
                    //Console.WriteLine( "data is : " + value );
                }
                {
                    int final_value = srg.GetEntropy(512 - n, false);
                    collector.AddBits((uint)final_value, 512 - n);
                }
                byte[] one = srg.entropy;
                byte[] two = collector.buffer;
                for (n = 0; n < 512 / 8; n++)
                {
                    if (one[n] != two[n])
                    {
                        Console.WriteLine("Byte " + n + " differed " + one[n].ToString("x") + " " + two[n].ToString("x"));
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void Test()
        {
            SaltyRandomGenerator srg = new SaltyRandomGenerator();

            srg.getsalt += srg_getsalt;
            int n;

            for (n = 0; n < 500; n++)
            {
                Console.WriteLine("data is : " + srg.GetEntropy(1, true));
            }
            srg.Reset();
            for (n = 0; n < 500; n++)
            {
                Console.WriteLine("data is : " + srg.GetEntropy(1, false));
            }
        }