[Released] SecurePlayerPrefs

Easily encrypt your serialized classes and PlayerPrefs!
Replaces PlayerPrefs with an encrypted implementation.

Features:

  • Easy to use!
  • Supports serialized classes!
  • Tight and very short code.
  • Works also on mobile!
  • Only two scripts!

Output

Demoscript

using UnityEngine;
using System.Collections;
using SecPlayerPrefs;

public class SecurePlayerPrefsDemo : MonoBehaviour {

    void Start () {
 
        //Write
        SecurePlayerPrefs.SetFloat("float", 0.1f);
        SecurePlayerPrefs.SetBool("bool", true);
        SecurePlayerPrefs.SetInt("int", 100);
        SecurePlayerPrefs.SetString("string", "amazing!");

        //Read
        Debug.Log(SecurePlayerPrefs.GetFloat("float"));
        Debug.Log(SecurePlayerPrefs.GetBool("bool"));
        Debug.Log(SecurePlayerPrefs.GetInt("int"));
        Debug.Log(SecurePlayerPrefs.GetString("string"));

        //Serialized Classes
        //Write
        SecureplayerPrefsDemoClass c = new SecureplayerPrefsDemoClass();
        SecureDataManager<SecureplayerPrefsDemoClass> dataManager = new SecureDataManager<SecureplayerPrefsDemoClass>("name");
        c.incremental = true;
        c.playID = "tester";
        c.type = 10;
        dataManager.Save(c);

        //Read
        SecureDataManager<SecureplayerPrefsDemoClass> dataManagerReader =
    new SecureDataManager<SecureplayerPrefsDemoClass>("name");
        c = dataManagerReader.Get();
        Debug.Log(c.incremental);
        Debug.Log(c.type);
        Debug.Log(c.playID);

    }
}

using System;

[Serializable()]//Important
public class SecureplayerPrefsDemoClass
{
    public string playID { get; set; }
    public int type { get; set; }
    public bool incremental { get; set; }

    public SecureplayerPrefsDemoClass()
    {
        this.playID = "";
        this.type = 0;
        this.incremental = false;
    }
}

Buy Now!

SecurePlayerPrefs has been accepted at the Asset store!

Free voucher: gonna

Hi!

Thanks for SecurePlayerPrefs. I was wondering if there is a reason for not to have default values for the Set methods like PlayerPrefs has?

I made that change myself but it would be nice if it was included if I you release an updated version.

Another question. Should this work also on Android?

Br,

Kalle

Hi what do you mean with defaul values? Can you show me this?

Sure this works on every platform I guess. I personally use it for Android

Hi!

Sorry, I made a mistake by talking about Set methods, I meant Get methods instead.

By default values I mean override or optional second parameter for each Get method to allow setting default value if Key does not exist. PlayerPrefs has, for example, PlayerPrefs.GetString(“Keyname”, “default”); which will return “default” if key does not exist.

This was easy to implement but I’m not sure if that was the reason SecurePlayerPrefs didn’t seem to work on Android device… My game starts normally but after that Get or Set does not work and I get some exception or error somewhere (didn’t do any debuggin yet). When I reverted back to regular PlayerPrefs it worked again.

EDIT: Now that I have debugged the crash more it is not caused by SecurePlayerPrefs, it seems I failed miserably with my first implementation of default parameters for Get methods. Now it is working nicely also on my Android device :slight_smile:

Br,

Kalle