playMaker

Author Topic: PlayerPrefs Encryption  (Read 2277 times)

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
PlayerPrefs Encryption
« on: March 09, 2015, 07:02:02 PM »
Playmaker PlayerPrefs Encryption

Description:
General encryption tools using Playmaker actions.
Playmaker actions for encrypted string, int and float for PlayerPrefs.

3 types of actions:
1. Simple String encryption and decryption: Great for manually saving encrypted string to PlayerPrefs, database or send over a network (i.e. multiplayer). Anything that can be converted to a string can be encrypted and decrypted.

2. Md5 hash PlayerPrefs encryption: Will produce a hash value of the string, int or float – User may see the PlayerPrefs data but if they tamper with the data they will lose their original data. The Md5 encrypted hash key has to match the PlayerPrefs data for the PlayerPrefs data to be accepted by the game. -- still works if needed

3. PlayerPrefs Encryption: Encrypt string, int or float directly to PlayerPrefs. Decrypt string, int or float directly from PlayerPrefs.

Current version:
Version: 1.0.2 broken
Version: 1.0.1beta - android build error
Version:1.0beta - PlayerPrefs Encryption bug.

upgrade note: backup work then open latest unitypackage. nothing else is required.


Note: It works but it has some bugs and the code is not clean – test well before production release and if you get an error please check that encryption setup match 100% decryption setup!!! This is the first time I have ever script programmed outside of playmaker. This is open source so if you want to make it better please do so but you have to share the changes with the community.

Usage / information:
PlaymakerPlayerPrefsManager must be in all scenes (with same pswd, settings, etc) for required actions to work (PlayMaker/Addons/PlayerPrefs Encryption/Add PlayerPrefs Encryption Manager to scene).

Then leave ‘the don’t destroy on load’ to have it in all scenes or create a new prefab of the gameobject and load when needed.
 
You may have one setup for all the actions or you may setup each action with it’s own password/encryption format/etc. You cannot change the password after the production build as the user will not be able to read their PlayerPrefs if you do so but you may add new PlayerPrefs elements with a new passwords in the production build.

After each change in PlaymakerPlayerPrefsManager, please press ‘Setup’ button (beta feature).

Cryptology is (strongest to weakest): AES (128bits, 192bits, 256bits), Rijndael (locked at 128bits – same as AES but locked), RC2 (128bits), TripleDES (128bits, 192bits), XOR, Simple Gibberish. All other elements (loops, hash keys, vectors, etc) may be customised for your needs in PlaymakerPlayerPrefsManager including a basic password generator.

Time debug will measure the time it takes to complete the encryption or decryption action (onEnter to Finish). To include it into debug build, just // #if UNITY_EDITOR/#endif (or replace UNITY_EDITOR by UNITY_ANDROID or UNITY_IOS without //) in the needed playmaker action(s). Working on improving this feature.

Use the standard ‘Player Prefs Delete Key’ or ‘Player Prefs Delete All’ to delete the encryption keys. Only the data is encrypted and not the key name.

Compatible PC/Mobile

I tried to make it as simple and noob friendly as possible but feature rich. Information is marked in the asset or console when error.

Update Notes:
(1)
To Hash (MD5 + SH1) please use these simple but very effective actions:
http://hutonggames.com/playmakerforum/index.php?topic=10522.0
http://hutonggames.com/playmakerforum/index.php?topic=10523.0
http://hutonggames.com/playmakerforum/index.php?topic=10524.0
http://hutonggames.com/playmakerforum/index.php?topic=10526.0
http://hutonggames.com/playmakerforum/index.php?topic=10465.0

The MD5 hashing actions from this package will be deprecated soon.

License:
Attribution 4.0 International (CC BY 4.0) + no credit required.
« Last Edit: November 13, 2016, 10:55:15 AM by dudebxl »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12098
  • Official Playmaker Support
    • View Profile
Re: PlayerPrefs Encryption
« Reply #1 on: March 09, 2015, 11:44:16 PM »
Hi,

 thanks for this! I have added it to the list of addons on the wiki

Bye,

 Jean

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: PlayerPrefs Encryption
« Reply #2 on: June 23, 2015, 03:33:54 AM »
update bump ***