I have made Game in Unity , which contains lots of public and private varibles and functions. I wanted the game to be secure , so I bought Anti cheat toolkit from unity asset store https://www.assetstore.unity3d.com/en/#!/content/10395 .So my question is do i need secured private variables ? If yes, then what is the use of private variables? What advantages do they have (in security terms) ?
do I need to secure private variables ?
No, both public and private variables have the same security defences (or rather no security defences). If an attacker can view or modify a public variable, they can view or modify a private variable.
Access modifiers are there for programmer convenience and to help with architectural decisions.
Private and public identifiers have nothing to do with security, but rather the visibility/accessibility of a method/variable/whatever.
A private var communicates to the developer that this variable is used only by its class and should not be touched/accessed anywhere else.
A public var communicates that the variable is accessed somewhere else and the value of the variable matters to the functionality to parts of the codebase/users
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With