什么是在PHP Web服务和Android / Java应用程序之间保护数据的最佳方法

问题描述:

And by that i don't mean using HTTPS, but data encryption.

Is there a nice encryption method that i can use in PHP to encrypt the data and decrypt in Java?

Thanks in advance.

由此我不是指使用HTTPS,而是使用数据加密。 p>

我可以在PHP中使用加密方法加密数据并用Java解密吗? p>

提前致谢。 p > div>

AES-256 is the same in both Java as PHP: the algorithm itself is naturally language agnostic, so you can just pick one. That said, if you were to use HTTPS, the data would be encrypted either way, so perhaps you're overcomplicating things? Is the data that important and privacy-sensitive?

HTTPS does data encryption. If you're planning to negotiate the encryption without any pre-shared keys then HTTPS is probably one of your best options. It's not trivial to get encryption done in a proper way, so it's usually best to leverage existing implementations.

If you are planning on using a shared key that the client and server each know about, then you do likely want to use AES. For the Java side see an example here. You'll have to search around for the PHP side. Be sure to follow all of the best practices if you're aiming for security.