예제 #1
0
 /// <summary>
 /// Helper method that can handle any of the encrypted player pref types, returning a float, int or string based
 /// on what type of value has been stored.
 /// </summary>
 public static object GetEncryptedValue(string encryptedKey, string encryptedValue)
 {
     // See what type identifier the encrypted value starts
     if (encryptedValue.StartsWith(VALUE_FLOAT_PREFIX))
     {
         // It's a float, so decrypt it as a float and return the value
         return(GetEncryptedFloat(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else if (encryptedValue.StartsWith(VALUE_INT_PREFIX))
     {
         // It's an int, so decrypt it as an int and return the value
         return(GetEncryptedInt(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else if (encryptedValue.StartsWith(VALUE_STRING_PREFIX))
     {
         // It's a string, so decrypt it as a string and return the value
         return(GetEncryptedString(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else if (encryptedValue.StartsWith(VALUE_BOOL_PREFIX))
     {
         // It's a string, so decrypt it as a string and return the value
         return(GetEncryptedBool(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else
     {
         throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
     }
 }
예제 #2
0
 public static string DecryptKey(string encryptedKey)
 {
     if (encryptedKey.StartsWith("ENC-"))
     {
         return(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)));
     }
     throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
 }
예제 #3
0
        public static string GetEncryptedString(string key, string defaultValue = "")
        {
            string str = PlayerPrefs.GetString("ENC-" + SimpleEncryption.EncryptString(key));

            if (!string.IsNullOrEmpty(str))
            {
                return(SimpleEncryption.DecryptString(str.Remove(0, 1)));
            }
            return(defaultValue);
        }
예제 #4
0
    // Token: 0x06004DB4 RID: 19892 RVA: 0x001A112C File Offset: 0x0019F52C
    public static string GetEncryptedString(string key, string defaultValue = "")
    {
        string key2 = "ENC-" + SimpleEncryption.EncryptString(key);
        string text = PlayerPrefs.GetString(key2);

        if (!string.IsNullOrEmpty(text))
        {
            text = text.Remove(0, 1);
            return(SimpleEncryption.DecryptString(text));
        }
        return(defaultValue);
    }
예제 #5
0
 /// <summary>
 /// Decrypts the specified key
 /// </summary>
 public static string DecryptKey(string encryptedKey)
 {
     if (encryptedKey.StartsWith(KEY_PREFIX))
     {
         // Remove the key prefix from the encrypted key
         string strippedKey = encryptedKey.Substring(KEY_PREFIX.Length);
         // Return the decrypted key
         return(SimpleEncryption.DecryptString(strippedKey));
     }
     else
     {
         throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
     }
 }
예제 #6
0
 public static object GetEncryptedValue(string encryptedKey, string encryptedValue)
 {
     if (encryptedValue.StartsWith("0"))
     {
         return((object)PlayerPrefsUtility.GetEncryptedFloat(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)), 0.0f));
     }
     if (encryptedValue.StartsWith("1"))
     {
         return((object)PlayerPrefsUtility.GetEncryptedInt(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)), 0));
     }
     if (encryptedValue.StartsWith("2"))
     {
         return((object)PlayerPrefsUtility.GetEncryptedString(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)), string.Empty));
     }
     throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
 }
예제 #7
0
    /// <summary>
    /// Encrypted version of PlayerPrefs.GetString(), an unencrypted key is passed and the value is returned decrypted
    /// </summary>
    public static string GetEncryptedString(string key, string defaultValue = "")
    {
        // Encrypt and prefix the key so we can look it up from player prefs
        string encryptedKey = KEY_PREFIX + SimpleEncryption.EncryptString(key);

        // Look up the encrypted value
        string fetchedString = PlayerPrefs.GetString(encryptedKey);

        if (string.IsNullOrEmpty(fetchedString))
        {
            return(defaultValue);
        }

        // Strip out the type identifier character
        fetchedString = fetchedString.Remove(0, 1);

        // Decrypt and return the string value
        return(SimpleEncryption.DecryptString(fetchedString));
    }