php 安全保护与私有
我正在尝试在 php 中构建一个应用程序,并且我有一个正在部署的加密/解密方法,为了增强安全性,我将这两个方法声明为受保护的,并且我计划让任何需要它们的类从它们继承。这有什么缺点吗?又名恶意用户可以利用他们被声明为受保护的事实吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
私有/受保护/公共(即可见性)的概念与安全性完全无关。它与封装的概念有关。
The concept of private/protected/public (i.e. visibility) has nothing to do with security at all. It's related to concept of encapsulation.
我认为受保护的、私有的或公共的不应该用于这种安全。它更多的是用于正确的面向对象编程的工具,而不是用于安全性的工具。
如果攻击者实际上可以插入可能利用此类漏洞的代码,那么您不必担心它是否是私有的或受保护的。
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.