使用 PHP 的最简单的双向加密 [英] Simplest two-way encryption using PHP

查看:22
本文介绍了使用 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()

正如 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-葬礼

There is even an RFC to remove Mcrypt from PHP - https://wiki.php.net/rfc/mcrypt-viking-funeral

这篇关于使用 PHP 的最简单的双向加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆