Search Unity

PrefCrypt - Simple Encryption and PlayerPrefs Expansion

Discussion in 'Assets and Asset Store' started by Pixelith, Apr 19, 2017.

  1. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Asset Store Link
    Here

    Documentation
    Here


    PrefCrypt is a very simple script for quick encryption and decryption of values while expanding on PlayerPrefs. Works the same as PlayerPrefs just with more compatibility.

    Currently supported
    • String , String [ ]
    • Int , Int [ ]
    • Long , Long [ ]
    • Float , Float [ ]
    • Bool , Bool [ ]
    • Color , Color [ ]
    • Vector4, Vector4 [ ]
    • Vector3 , Vector3 [ ]
    • Vector2 , Vector2 [ ]
    • Double , Double [ ]
    • Rect , Rect [ ]
    • DateTime , DateTime [ ]
    • Quaternion, Quaternion [ ]
    • Transform , Transform [ ]


    With an expansion to what you can save, along with added Encryption, you'll have values that your average player can't edit so easily anymore.


    With new editor
    PrefCryptSettings.PNG




    Example.PNG

    That is an example on what you would have to do on your end to save or load in your existing code.
    The reason I have DateTime in a Debug is because you can't exactly have it as an inspector variable, so I needed a way of testing it. You might also notice how GetTransform is different from the others. The reason being is because Transforms need an object to exist. So to get around this, I simply reference the object's transform in the GetTransform function. It works the same as every other function this way.

    If you were to try and use a regular PlayerPrefs to get something saved with PrefCrypt, it would return 0 or a strange negative. Same the other way around. If you saved with normal PlayerPrefs, you can't use PrefCrypt to access it.

     
    Last edited: Mar 16, 2018
  2. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update: I'm currently adding support for arrays. It's a lot more simple than I thought.
     
  3. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update: Added in Array variables. So now it supports Encrypted PlayerPrefs of

    • String , String [ ]
    • Int , Int [ ]
    • Long , Long [ ]
    • Float , Float [ ]
    • Bool , Bool [ ]
    • Color , Color [ ]
    • Vector3 , Vector3 [ ]
    • Vector2 , Vector2 [ ]
    • Double , Double [ ]
    • Rect , Rect [ ]
    • DateTime , DateTime [ ]
    • Transform , Transform [ ]
    With this I've submitted it to the asset store. It'll be priced at $5. Because I couldn't add any external editors or something to watch over your saved variables, I felt this was an appropriate price for the work I put in. If it's accepted, I hope to add those kind of features in a later update to help make management of saved variables easier.
     
    Last edited: Apr 21, 2017
  4. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update: It got declined, sadly. Apparently due to me referencing my youtube as my website instead of a GitHub or Linkedin. I'll be fixing these up and resubmitting. Before I do, any features suggested for this? I'm open to anything if it adds to the features.
     
  5. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    It's now live in the Asset Store! I hope to see some feedback
     
  6. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update: Submitted for review is a minor update, adds null returns and prints if you use Get with no saved variable
     
  7. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update: It will now include a small Example Scene with a player script to show how it saves usual values such as Int, Extended values like color and Transform, and then arrays.
    Also made a quick video to show how easy it is to use
     
  8. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    v1.2 with Example scene is now live
     
  9. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    Nice asset. But it looks like the manual is missing information about how to store & load arrays. I had to look at the screenshots to figure out that I have to add Array to it. Like PrefCrypt.SetVector3Array()

    Will you add Vector4 and Quaternions?
     
    Pixelith likes this.
  10. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    And shouldn’t this thread belong to the Asset Store Forum?
     
    Pixelith likes this.
  11. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    I think it could go in either, but if it needs to be in the other I don't mind someone moving this for me lol. And thank you for the input, I'll be sure to update the manual. Quaternions is definitely doable and will be added. I'll have to research what a Vector 4 is but it shouldn't be too difficult to add
     
  12. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    BTW: Would be easier if we could copy/paste the code example from the manual. And if you would offer a download of the PDF just because it is nice to read that before buying it.
    I would also show an example on the Asset Store and in the manual how the encrypted PlayerPrefs finally looks like – just because this is what it is about.

    I think an option to encrypt the key too would be useful. That would make it even harder to try to cheat.
     
  13. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    I'll see about loading up the PDF somewhere. And well its hard to show what a playerpref looks like since it isn't stored as a value in the project, but on the device. Its why I tried to show in the video what happens and what I code I used. If you try to use a playerpref to call a prefcrypt variable, it usually just returns 0
     
  14. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    On the Mac you can open it in an plist editor (with Xcode for example). And make a screenshot of it:

     
    Pixelith likes this.
  15. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Ahhh, I had no idea that was a thing. I work on Windows and I have to go into regedit just to view it. I didn't know exactly what values to show from in there so I left it be.
     
  16. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update sent in for approval. Adds Vector4 and Quaternion
     
    VIC20 likes this.
  17. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    Great, thank you!
     
    Pixelith likes this.
  18. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Update 1.3 is now on the Asset Store
     
  19. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Addition of the Read Me document and Video to the first post , so now you can get a feel for it before you buy
     
    Last edited: Sep 10, 2017
  20. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    Great, that’s better. But it would be most useful if you add the link to the manual to the description metadata on the store too.
     
  21. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Quick nudge over to assets forum because there wasn't a thread for it here.
     
    Pixelith likes this.
  22. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Thanks :)
     
  23. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    I just did, will take a bit for it to update
     
  24. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,689
    Just saw this change is online now. Much better.
     
    Pixelith likes this.
  25. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    After a couple months and learning a bit more, I decided to update this a bit. I'm going to be adding in a small editor for helping. It'll look like this
    PrefCryptSettings.PNG

    I figured this would be easier than opening up the script and changing the values, and would even give an area to delete playerprefs and test values. It's not done yet, but will be in the next 1-3 days. The price will be $2 once it does. Not a huge increase but I feel it reflects the amount of work done while keeping this cheap and affordable for small hobbyists.
     
    VIC20 likes this.
  26. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    An updated document was added to the link in the first post, and new update has been Submitted!
     
  27. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    It is now updated in the store!