示例#1
0
 public SocketServerTest()
 {
     m_testTimer = new Time();
     m_list = new List();
 }
示例#2
0
        static Boolean RunBase64Test()
        {
            string origninal = "Hello from RSA Crypto.";
            byte[] origin = ConvertToByteArray(origninal);

            string transformed = Convert.ToBase64String(origin);
            byte[] ba1 = ConvertToByteArray(transformed);
            List<byte> b = new List<byte>(ba1);
            b.Insert(0, 0x0d);
            b.Insert(5, 0x0a);
            byte[] ba2 = b.ToArray();

            MemoryStream ms1 = new MemoryStream();
            CryptoStream cs1 = new CryptoStream(ms1, new FromBase64Transform(), CryptoStreamMode.Write);
            cs1.Write(ba1, 0, ba1.Length);
            cs1.Close();

            MemoryStream ms2 = new MemoryStream();
            CryptoStream cs2 = new CryptoStream(ms2, new FromBase64Transform(), CryptoStreamMode.Write);
            cs2.Write(ba2, 0, (int)ba2.Length);
            cs2.Close();

            FromBase64Transform f = new FromBase64Transform();
            if (f.CanReuseTransform == false)
            {
                Log.Comment("Transofrm should be able to be reused");
                return false;
            }

            f.Clear();

            if (!Compare(ms1.ToArray(), ms2.ToArray())) return false;
            if (!Compare(ms1.ToArray(), origin)) return false;

            return true;
        }
示例#3
0
            public ProcessClientRequest(Socket clientSocket, Boolean asynchronously, Time timer, List list)
            {
                m_clientSocket = clientSocket;
                m_testTimer = timer;
                m_list = list;

                if (asynchronously)
                {
                    SocketServerTest.m_totalThreadCount++;
                    new Thread(ProcessRequest).Start();
                }
                else
                {
                    ProcessRequest();
                }
            }