Exemplo n.º 1
0
    private static void SaveStringValue(string key, string finalValue)
    {
        string encrypedKey    = Use_Encrypt ? SecurityUtility.GetInstance().EncryptString(key) : key;
        string encryptedValue = Use_Encrypt ? CombineEncryptKeyAndValue(key, finalValue) : finalValue;

        PlayerPrefs.SetString(encrypedKey, encryptedValue);
        PlayerPrefs.Save();
    }
Exemplo n.º 2
0
 private static string[] SplitDecryptKeyAndValue(string encryptString)
 {
     if (string.IsNullOrEmpty(encryptString) == false)
     {
         string decryptedString = SecurityUtility.GetInstance().DecryptString(encryptString);
         return(decryptedString.Split(new char[] { '@' }));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public static void UpgradeProfile()
 {
     foreach (GameSystem.Mode mode in Enum.GetValues(typeof(GameSystem.Mode)))
     {
         string key         = string.Format("BestScore_{0}", (int)mode);
         string encrypedKey = Use_Encrypt ? SecurityUtility.GetInstance().EncryptString(key) : key;
         if (PlayerPrefs.HasKey(encrypedKey))
         {
             int score = LoadIntValue(key, 0);
             SaveBestRecord(mode, GameSystem.ModeType.Challenge, score);
             PlayerPrefs.DeleteKey(encrypedKey);
         }
     }
 }
Exemplo n.º 4
0
    private static string LoadStringValue(string key)
    {
        string encrypedKey = Use_Encrypt ? SecurityUtility.GetInstance().EncryptString(key) : key;

        if (PlayerPrefs.HasKey(encrypedKey))
        {
            string savedString = PlayerPrefs.GetString(encrypedKey);
            if (Use_Encrypt)
            {
                string[] decryptStrings = SplitDecryptKeyAndValue(savedString);
                if (decryptStrings != null && decryptStrings.Length == 2)
                {
                    if (decryptStrings[0].Equals(key))
                    {
                        return(decryptStrings[1]);
                    }
                    else
                    {
                        return(String.Empty);
                    }
                }
                else
                {
                    return(String.Empty);
                }
            }
            else
            {
                return(savedString);
            }
        }
        else
        {
            return(String.Empty);
        }
    }
Exemplo n.º 5
0
 private static string CombineEncryptKeyAndValue(string key, string val)
 {
     return(SecurityUtility.GetInstance().EncryptString(key + "@" + val));
 }