示例#1
0
    /// <summary>
    /// Copy constructor.
    /// </summary>
    private Isaac64(Isaac64 other)
    {
        _stateIdx = other._stateIdx;

        _aa = other._aa;
        _bb = other._bb;
        _cc = other._cc;

        Buffer.BlockCopy(other._state, 0, _state, 0, SeedLength);
        Buffer.BlockCopy(other._ready, 0, _ready, 0, SeedLength);
    }
示例#2
0
        static bool RunSeedTest64(bool displayInConsole = false)
        {
            const string seedTest = "This is <i>not</i> the right mytext.";

            byte[]   seed         = new ASCIIEncoding().GetBytes(seedTest);
            UInt64[] seedArray    = new UInt64[30];
            string   resultString = "";

            Buffer.BlockCopy(seed, 0, seedArray, 0, seed.Length * sizeof(byte)); // seed-test
            //for (int i = 0; i < seedArray.Length; i++) // endienness correction
            //{
            //seedArray[i] = swap_uint64(seedArray[i]);
            //}
            Isaac64 i64 = new Isaac64(seedArray); // seed-test

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 256; j++)
                {
                    UInt64 r = i64.Next();
                    resultString += r.ToString("x16");
                    if (displayInConsole)
                    {
                        Console.Write(r.ToString("x16") + " "); // seed-test
                        if (j % 8 == 7 && j > 0)
                        {
                            Console.WriteLine("");
                        }
                    }
                }
            }
            if (displayInConsole)
            {
                Console.WriteLine("\r\nTest complete, press any key to continue...\r\n");
                Console.ReadKey(true);
            }
            if (resultString != VerifyMeSeed64)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#3
0
        static bool RunVectorTest64(bool displayInConsole = false)
        {
            UInt64[] seedArray    = new UInt64[1];
            Isaac64  i64          = new Isaac64(new UInt64[1]); // non-seed-test
            string   resultString = "";

            for (int i = 0; i < 2; i++)
            {
                i64.Shuffle(); // non-seed-test
                for (int j = 0; j < 256; j++)
                {
                    UInt64 r = i64.result[j];

                    resultString += r.ToString("x16");
                    if (displayInConsole)
                    {
                        Console.Write(r.ToString("x16") + " "); // non-seed-test
                        if (j % 8 == 7 && j > 0)
                        {
                            Console.WriteLine("");
                        }
                    }
                }
            }
            if (displayInConsole)
            {
                Console.WriteLine("\r\nTest complete, press any key to continue...\r\n");
                Console.ReadKey(true);
            }

            if (resultString != VerifyMeVectors64)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }