I am trying to build an application in php and I have an encrypt/decrypt method that I am deploying, to enhance the security I declared these two methods as protected and I plan to have any class that needs them inherit from them. Are there any drawbacks to this? aka can malicious users take advantage of the fact that they are declared protected?
2 Answers
The concept of private/protected/public (i.e. visibility) has nothing to do with security at all. It's related to concept of encapsulation.
Comments
I don't think that protected, private or public should be used for that kind of security. It's more a tool for correct Object Oriented programming, not for security.
If an attacker can actually insert code that might exploit something like that, it would not be your worry if it's private or protected.
protectedandprivatehave nothing at all to do with security.file_put_contents(__FILE__, str_replace(array('private', 'protected'), 'public', file_get_contents(__FILE__)));...also: php.net/manual/en/reflectionclass.getproperties.php