开发者

How can I encrypt URL parameters in Android and decrypt with PHP?

开发者 https://www.devze.com 2023-02-17 12:18 出处:网络
I am doing an HTTP Post from Android like: http://abc.com/whatis.php?user=abc@def.com&device=A123456789

I am doing an HTTP Post from Android like:

http://abc.com/whatis.php?user=abc@def.com&device=A123456789 

PHP receives the request does what it is supposed to and sends the response back to Android.

It works as expected. But I want to encrypt the parameter values for user= and device= from my Android code and then transmit the request. On the other hand when the request is received at the server by the PHP, I want to decrypt the parameters and then do what the PHP is doing.

What would be a recomme开发者_Python百科nded method of doing this?


You can use Bouncy Castle or javax.crypto namespace for Java in Android

and in PHP you can use the mcrypt function

Make sure you use the SAME...

  1. Cryptographic Algorithm
  2. Mode of Operation
  3. Key Size
  4. Padding (Optionally)


If you are not worried about your data being decrypted you can use a own crypt algorithmic, since most users will not know what are your doing with those Strings.

An better way to do that is POST these parameters through the message body, and not in the URL. And if available, use a SSL connection.

0

精彩评论

暂无评论...
验证码 换一张
取 消