Ejemplo n.º 1
0
        public static string DecryptKey(string encryptedKey)
        {
            if (encryptedKey.StartsWith(KeyPrefix))
            {
                var strippedKey = encryptedKey.Substring(KeyPrefix.Length);
                return(UserEncryption.DecryptString(strippedKey));
            }

            throw new InvalidOperationException(
                      "Could not decrypt item, no match found in known encrypted key prefixes");
        }
Ejemplo n.º 2
0
        public static string GetString(string key, string defaultValue = "")
        {
            var encryptedKey  = KeyPrefix + UserEncryption.EncryptString(key);
            var fetchedString = PlayerPrefs.GetString(encryptedKey);

            if (string.IsNullOrEmpty(fetchedString))
            {
                return(defaultValue);
            }
            fetchedString = fetchedString.Remove(0, 1);
            return(UserEncryption.DecryptString(fetchedString));
        }
Ejemplo n.º 3
0
        public static object GetValue(string encryptedKey, string encryptedValue)
        {
            if (encryptedValue.StartsWith(ValueFloatPrefix))
            {
                return(GetFloat(UserEncryption.DecryptString(encryptedKey.Substring(KeyPrefix.Length))));
            }

            if (encryptedValue.StartsWith(ValueIntPrefix))
            {
                return(GetInt(UserEncryption.DecryptString(encryptedKey.Substring(KeyPrefix.Length))));
            }

            if (encryptedValue.StartsWith(ValueStringPrefix))
            {
                return(GetString(UserEncryption.DecryptString(encryptedKey.Substring(KeyPrefix.Length))));
            }

            throw new InvalidOperationException(
                      "Could not decrypt item, no match found in known encrypted key prefixes");
        }