Beispiel #1
0
 void OnGUI()
 {
     GUILayout.Space(15);
     GUILayout.BeginHorizontal();
     GUILayout.Label("内容:", GUILayout.Width(40));
     content = EditorGUILayout.TextArea(content, GUILayout.MinWidth(300), GUILayout.MinHeight(200));
     content = content.Trim();
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("DES解密") || (Event.current.keyCode == KeyCode.Return))
     {
         if (string.IsNullOrEmpty(content))
         {
             return;
         }
         result = EncryptUtil.DESDecryptString(content, GameConfig.encryptKey);
         Debugger.Log(result);
     }
     if (GUILayout.Button("DES加密") || (Event.current.keyCode == KeyCode.Return))
     {
         if (string.IsNullOrEmpty(content))
         {
             return;
         }
         result = EncryptUtil.DESEncryptString(content, GameConfig.encryptKey);
         Debugger.Log(result);
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("移位解密") || (Event.current.keyCode == KeyCode.Return))
     {
         if (string.IsNullOrEmpty(content))
         {
             return;
         }
         byte[] bytes = ASCIIEncoding.ASCII.GetBytes(content);
         bytes  = EncryptUtil.MinusExcursionBytes(bytes, GameConfig.excursion);
         result = UTF8Encoding.UTF8.GetString(bytes);
         Debugger.Log(result);
     }
     if (GUILayout.Button("移位加密") || (Event.current.keyCode == KeyCode.Return))
     {
         if (string.IsNullOrEmpty(content))
         {
             return;
         }
         byte[] bytes = UTF8Encoding.UTF8.GetBytes(content);
         bytes  = EncryptUtil.PlusExcursionBytes(bytes, GameConfig.excursion);
         result = ASCIIEncoding.ASCII.GetString(bytes);
         Debugger.Log(result);
     }
     GUILayout.EndHorizontal();
     GUILayout.Space(15);
     GUILayout.BeginHorizontal();
     GUILayout.Label("结果:", GUILayout.Width(40));
     result = EditorGUILayout.TextArea(result, GUILayout.MinWidth(300), GUILayout.MinHeight(200));
     GUILayout.EndHorizontal();
 }
Beispiel #2
0
        /// <summary>
        /// 根据验证字符串获取登录信息
        /// 创建  毛枫  2015-4-21
        /// </summary>
        /// <param name="authStr"></param>
        /// <param name="userId"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        private static bool CheckAuthInfo(string authStr, ref int userId, ref string userName)
        {
            //解密验证字符串
            string decrypt = EncryptUtil.DESDecryptString(authStr);

            if (string.IsNullOrEmpty(decrypt))
            {
                return(false);
            }
            string[] infoTmp = decrypt.Split('^');
            if (infoTmp.Length < 3)
            {
                return(false);
            }

            try
            {
                userId   = Convert.ToInt32(infoTmp[0]);
                userName = infoTmp[1];
                DateTime expireTime = Convert.ToDateTime(infoTmp[2]);
                //判断该验证字符串是否过期
                if (expireTime.CompareTo(DateTime.Now) < 0)
                {
                    return(false);
                }
                else
                {
                    if (System.Web.HttpContext.Current.Session["A_Id"] != null && Convert.ToInt32(System.Web.HttpContext.Current.Session["A_Id"]) == userId &&
                        System.Web.HttpContext.Current.Session["A_AdminName"] != null && System.Web.HttpContext.Current.Session["A_AdminName"].ToString() == userName)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch
            {
                return(false);
            }
        }