Example #1
0
        public static string GetRandomKey(int length)
        {
            string ret = string.Empty;
            int    i   = length;

            while ((i--) > 0)
            {
                Random rd = new Random();
                ret = ret + MiddleWare.intToHexString(rd.Next(1, 255));
            }
            return(ret);
        }
Example #2
0
        public static string GetServerIP()
        {
            string IP = string.Empty;

            if (GlobalVar.g_IPSequence > 8)
            {
                GlobalVar.g_IPSequence = 1;
            }
            if (GlobalVar.g_IPSequence == 0)
            {
                IP = MiddleWare.HostNameToIP("183.60.56.29");
            }
            if (GlobalVar.g_IPSequence == 1)
            {
                IP = MiddleWare.HostNameToIP("sz2.tencent.com");
            }
            if (GlobalVar.g_IPSequence == 2)
            {
                IP = MiddleWare.HostNameToIP("sz3.tencent.com");
            }
            if (GlobalVar.g_IPSequence == 3)
            {
                IP = MiddleWare.HostNameToIP("sz4.tencent.com");
            }
            if (GlobalVar.g_IPSequence == 4)
            {
                IP = MiddleWare.HostNameToIP("sz5.tencent.com");
            }
            if (GlobalVar.g_IPSequence == 5)
            {
                IP = MiddleWare.HostNameToIP("sz6.tencent.com");
            }
            if (GlobalVar.g_IPSequence == 6)
            {
                IP = MiddleWare.HostNameToIP("183.60.56.29");
            }
            if (GlobalVar.g_IPSequence == 7)
            {
                IP = MiddleWare.HostNameToIP("sz8.tencent.com");
            }
            if (GlobalVar.g_IPSequence == 8)
            {
                IP = MiddleWare.HostNameToIP("sz9.tencent.com");
            }
            return(IP);
        }
Example #3
0
        public static string DecToHex(int n)
        {
            string hex = string.Empty;

            if (n < 256)
            {
                string str = "0" + MiddleWare.intToHexString(n);
                return(str.Substring(str.Length - 2));
            }

            if (n >= 256)
            {
                string str = "0" + MiddleWare.intToHexString(n);
                hex = str.Substring(str.Length - 4);
                return(hex.Substring(0, 2) + " " + hex.Substring(hex.Length - 2));
            }
            return(string.Empty);
        }