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"); }
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)); }
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"); }