Ejemplo n.º 1
0
    /// <summary>
    /// Writes the config file.
    /// </summary>
    public static void WriteConfigFile()
    {
        try{
            using (FileStream t_file = new FileStream(Application.persistentDataPath + ConfigFilename, FileMode.Create, FileAccess.Write)){
                using (StreamWriter t_sw = new StreamWriter(t_file)){
                    t_sw.WriteLine(ConfigFileVersion);

                    t_sw.WriteLine(Setting_IsAutoLogin);                        // auto login
                    t_sw.WriteLine(Setting_IsGuest);                            // auto login
                    t_sw.WriteLine(Setting_IsRemberPassword);
                    t_sw.WriteLine(Setting_LoginName);                          // username
                    Debug.Log(Setting_LoginName);
                    t_sw.WriteLine(CryptHelper.AESEncrypt(Setting_LoginPass));  // password (must be crypted)
                    t_sw.WriteLine(Setting_LogingServer);                       // server

                    t_sw.WriteLine(Setting_ScreenQuality);                      // screen high/low quanlity
                    t_sw.WriteLine(Setting_Gravity);                            //  gravity enabled
                    t_sw.WriteLine(Setting_UserDefined);                        // is user changed
                    t_sw.WriteLine(Setting_MusicVol);                           // music volume
                    t_sw.WriteLine(Setting_SoundVol);                           // sound volume
                    t_sw.WriteLine(Setting_Language);                           // language

                    t_sw.WriteLine(Setting_SkipCopyCameraTrack);                // language
                    t_sw.WriteLine(Setting_ShakeEnable);
                }
            }
        }catch (System.Exception ex) {
            Debug.LogError("Write config file failed, Exception:" + ex.Message);
        }
    }
Ejemplo n.º 2
0
        //title="userId & createTime & expiredDuration & 签名"

        /// <summary>
        /// 创建Token
        /// </summary>
        /// <param name="UserId">当前用户ID</param>
        /// <param name="expiredDuration">Token的有效时长(单位:分钟)</param>
        /// <returns>Token字符串</returns>
        public string CreateToken(string UserId, int expiredDuration)
        {
            string timeStamp  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string strHashed  = HashBuilder.GetHMACMD5Hash(UserId + timeStamp + expiredDuration.ToString());
            string concatData = UserId + "&" + timeStamp + "&" + expiredDuration.ToString() + "&" + strHashed;

            return(CryptHelper.AESEncrypt(concatData));
        }