i am going to start a new project (aiming to put it on steam) but i want to prevent players from cheating because i use PlayerPrefs to save players data.
so my question when should i encrypt these data? at the beginning of the project or when i finished every thing?
also Is there any good asset to encrypt the data instead of me doing all the things?
PlayerPrefs are really not the way to go if you want to make data save and have people compete on leaderboards against each other.
There are certainly assets on the asset store to encrypt PlayerPrefs, but that system is meant for storing the players preference like audio volume, nothing else.
Here is my recommendation:
For real score keeping you should consider binary data. And once you’re there, you could also think about obfuscating the Assembly, but that’s a much bigger topic.
Here’s a tutorial that gives you an introduction to binary save:
Unity official live training - Data Persistence
And here is a nice article about some general ideas:
Gamasutra - Six Strategies for Protecting Your Mobile Games
Good luck and keep at it!
If you want to keep your data safe, rather keep it in the cloud and use a backend as a service like GameSparks to manage it.
This is a lot more powerful than storing data locally and allows you to monitor/track all data, and change it on the server as neccessary.
Personally, I would only use PlayerPrefs for something like AudioVolume or other local system settings, anything else is easily hackable, encrypted or not.