使用PHP进行最简单的双向加密 [英] Simplest two-way encryption using PHP
问题描述
在常见的PHP安装中,最简单的方法是进行双向加密?
What is the simplest way of doing two way encryption in common PHP installs?
我需要使用字符串键加密数据,并使用相同的方法关键是在另一端解密。
I need to be able to encrypt data with a string key, and use the same key to decrypt on the other end.
安全性并不像代码的可移植性那么大,所以我想保持事情尽可能简单。目前,我正在使用一个RC4实现,但是如果我能找到一些本地支持的东西,我可以保存很多不必要的代码。
The security isn't as big of a concern as the portability of the code, so I'd like to be able to keep things as simple as possible. Currently, I am using an RC4 implementation, but if I can find something natively supported I figure I can save a lot of unnecessary code.
推荐答案
已编辑
您应该真正使用 openssl_encrypt()& openssl_decrypt()
You should really be using openssl_encrypt() & openssl_decrypt()
As Scott 表示,Mcrypt不是一个好主意,因为它自2007年以来还没有更新。
As Scott says, Mcrypt is not a good idea as it has not been updated since 2007.
甚至有一个RFC从PHP中删除Mcrypt - https://wiki.php .net / rfc / mcrypt-viking-funeral
There is even an RFC to remove Mcrypt from PHP - https://wiki.php.net/rfc/mcrypt-viking-funeral
这篇关于使用PHP进行最简单的双向加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!