protected void Page_Load(object sender, EventArgs e)
        {
            ILog logger = LogManager.GetLogger("DoGetDownloadURL");

            try
            {
                string msisdn    = Request.QueryString["Msisdn"];
                string reqTime   = Request.QueryString["reqTime"];
                string shortCode = Request.QueryString["shortcode"];
                string reqId     = Request.QueryString["reqId"];
                string username  = Request.QueryString["username"];
                string password  = Request.QueryString["password"];
                string gameId    = Request.QueryString["GameID"];

                logger.Debug(" ");
                logger.Debug(" ");
                logger.Debug("----- VMS API CALL DoGetDownloadURL ----- :" + "msisdn : " + msisdn + " |reqTime : " + reqTime +
                             " |shortCode : " + shortCode + " |reqId : " + reqId + " |userName : "******" |password : "******" |GameId : " + gameId);
                logger.Debug(" ");
                logger.Debug(" ");

                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    var item = new VmsAppboxGamelinkLog();
                    item.GameId    = ConvertUtility.ToInt32(gameId);
                    item.Msisdn    = msisdn;
                    item.ReqTime   = reqTime;
                    item.ShortCode = shortCode;
                    item.ReqId     = reqId;
                    item.UserName  = username;
                    item.Password  = password;

                    ApiController.ApiVmsAppboxGamelinkLog(item);

                    string key = DateTime.Now.ToString("ddMMyyyy") + gameId;
                    key = SecurityMethod.MD5Encrypt(key);

                    string        strValue     = string.Format("gameid={0}|reqid={1}|msisdn={2}|key={3}|source={4}|type={5}", gameId, reqId, msisdn, key, "WAP", "2");
                    byte[]        dataEncode   = Encoding.UTF8.GetBytes(strValue);
                    Base64Encoder myEncoder    = new Base64Encoder(dataEncode);
                    StringBuilder encodevaulue = new StringBuilder();
                    encodevaulue.Append(myEncoder.GetEncoded());

                    string url = "http://vmgame.vn/wap/dlgame.ashx?value=" + encodevaulue;
                    logger.Debug("----- VMS API CALL DoGetDownloadURL URL RESPONSE ----- :" + url);

                    Response.Write(url);
                }
            }
            catch (Exception ex)
            {
                logger.Debug(" ");
                logger.Debug(" ");
                logger.Debug("----- VMS API CALL DoGetDownloadURL ----- :" + ex);
                logger.Debug(" ");
                logger.Debug(" ");
            }
        }
 //Encode a common string to base64 text
 public static string EncodeString2base(string NeedEncodeStr)
 {
     byte[] data = System.Text.UnicodeEncoding.UTF8.GetBytes(NeedEncodeStr);
     Base64Encoder myEncoder = new Base64Encoder(data);
     StringBuilder sb = new StringBuilder();
     sb.Append(myEncoder.GetEncoded());
     return sb.ToString();
 }
Ejemplo n.º 3
0
            public static char[] Encode(string input)
            {
                //first get the bytes for the original
                byte[] data=System.Text.UnicodeEncoding.UTF8.GetBytes(input);
                Base64Encoder myEncoder=new Base64Encoder(data);

                return myEncoder.GetEncoded();
            }
Ejemplo n.º 4
0
			public static string Encode(byte[] input)
			{
				//first get the bytes for the original
				Base64Encoder myEncoder=new Base64Encoder(input);

				StringBuilder sb=new StringBuilder();
				sb.Append(myEncoder.GetEncoded());
				return sb.ToString();
			}
Ejemplo n.º 5
0
        public void TestGetEncoded03()
        {
            Base64Decoder baseDecoder = new Base64Decoder("testingwithoutequal".ToCharArray());

            byte[]        decodedbyte = baseDecoder.GetDecoded();
            Base64Encoder baseEncoder = new Base64Encoder(decodedbyte);

            //Test Procedure Call
            char[] encodedstr = baseEncoder.GetEncoded();
            //Post Condition Check
            //Assert.AreEqual("testing=", encodedstr.ToString());
        }
Ejemplo n.º 6
0
        public static string Encrypt(string text)
        {
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            byte[] textBytes = encoding.GetBytes(text + HexMD5.Encode(KeyPairs.KEY_PAIR_1));
            byte[] keyBytes  = encoding.GetBytes(HexMD5.Encode(KeyPairs.KEY_PAIR_2));

            int length = textBytes.Length > keyBytes.Length ? keyBytes.Length : textBytes.Length;

            for (int i = 0; i < length; i++)
            {
                textBytes[i] += keyBytes[i];
            }


            Base64Encoder base64Encoder = new Base64Encoder(textBytes);

            byte[] encodedBytes = encoding.GetBytes(base64Encoder.GetEncoded());


            return(encoding.GetString(encodedBytes));
        }
Ejemplo n.º 7
0
        public bool SendPacket(string data, EncodingType ET)
        {
            bool ret = false;

            //
            try
            {
                byte[] buffer = new byte[data.Length];
                //Console.BackgroundColor = ConsoleColor.Gray;
                //Console.WriteLine(data);
                //Console.BackgroundColor = ConsoleColor.Black;
                Client.Client.SendBufferSize = buffer.Length;
                //Encode(data, out data, ET);
                buffer = E.GetBytes(data);
                //ns.Write(buffer, 0, data.Length);
                Base64Encoder B64 = new Base64Encoder(buffer);
                buffer = E.GetBytes(B64.GetEncoded());
                Client.Client.SendBufferSize = buffer.Length;
                Client.Client.Send(buffer);
                ret = true;
            }
            catch { }
            return(ret);
        }
Ejemplo n.º 8
0
 public void GetEncodedTest()
 {
     byte[] input = {64, 65, 66};
     var target = new Base64Encoder(input);
     char[] expected = {'Q', 'E', 'F', 'C'};
     char[] actual = target.GetEncoded();
     CollectionAssert.AreEqual(expected, actual, "Kfd.Tools.Base64Encoder.GetEncoded did not return the expected value.");
 }
        /// <summary>
        /// 字符串Base64编码
        /// </summary>
        /// <param name="srcString">需编码字符串</param>
        /// <param name="encoding">系统字符编码方式</param>
        /// <returns></returns>
        public static string Base64Encode(string srcString, System.Text.Encoding encoding)
        {
            if (null == srcString || string.Empty == srcString)
                return string.Empty;

            string result = string.Empty;
            Base64Encoder ec = new Base64Encoder();
            result = ec.GetEncoded(encoding.GetBytes(srcString));

            return result;
        }