php中的简单对称加密算法
我正在 php 中寻找简单的对称算法(处理能力低)。
加密值将作为 session_id 存储在客户端。并将已登录状态保存在其中。
我还需要在服务器端解密它。 请建议....
I am looking for simple symmtric algorithm (low on processing power) in php.
An encrypted value will be stored as a session_id on client end. And will have logged in status saved in it.
Also I need to also decrypt it on server side.
Please suggest....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您提到的唯一限制是低处理影响 - 但您没有提供所需算法强度的详细信息。
此外,如果加密是在 PHP 中实现的,那么它的效率将比 mcrypt 扩展(和其他扩展)提供的本机代码低几个数量级。
为什么???
会话 ID 是随机生成的,因此不可预测/猜测。会话提供了一种在服务器上存储数据的机制。如果问题是由于共享托管限制而在会话外维护数据的安全,那么这不是解决问题的正确方法。
有各种算法的原生 PHP 实现,TEA 是一个明显的选择,即使 mcrypt/openssl 扩展不可用,str_rot13() 也可用。但我看不出这些方法对任何问题的逻辑应用。
The only constraint you've mentioned is low processing impact - but you've provided no details of the strength of the algorithm required.
Also, if the encryption is implemented in PHP, then it will be several orders of magnitude less efficient than native code as provided by the mcrypt extension (and others).
Why????
The session id is randomly generated and therefore not predictable / guessable. And sessions provide a mechanism for storing data on the server. If the issue is to maintain secure data outside of the session due to shared hosting constraints, then this is not the right way to solve the problem.
There are native PHP implementations of various algorithms, TEA being an obvious choice, and str_rot13() is available even if mcrypt/openssl extensions are unavailable. But I can see no logical application of these methods to any problem.
我建议您使用 mcrypt 扩展。 这里有一些简单的例子。
它为您提供许多对称加密。
I suggest you use the mcrypt-extension. there you go for some simple examples.
It offers you many symmetric encryptions.