コード例 #1
0
ファイル: SaltyRandomGenerator.cs プロジェクト: d3x0r/xperdex
 public SaltyRandomGenerator(SaltyRandomGenerator clone)
 {
     this.entropy    = clone.entropy;
     this.bits_avail = clone.bits_avail;
     this.bits_used  = clone.bits_used;
     this.getsalt    = clone.getsalt;
 }
コード例 #2
0
ファイル: SaltyRandomGenerator.cs プロジェクト: d3x0r/xperdex
        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"));
                    }
                }
            }
        }
コード例 #3
0
ファイル: ShuffleSpots.cs プロジェクト: d3x0r/xperdex
 static ShuffleSpots()
 {
     rng          = new SaltyRandomGenerator();
     rng.getsalt += rng_getsalt;
 }