dongnue4923 2015-06-15 07:33
浏览 104
已采纳

保护C#和PHP之间的通信(而不是加密数据)

I'm developing an Android and iOS game, I need to call the php pages to collect and enter data into the database mysql.

Sending and reception of data works properly, the problem is that the data sent is not encrypted, but this I can solve it with the ssl certificates, in order to have all the data send encrypted.

The other problem is that with some appropriate programs (example: Charles Proxy) you can see the address pointed to my php file, and consequently you can resubmit the packet over and over again.

For example:

This is my test.php:

$code = $_POST['SecretCode'];

if($code == "secretcode")
{ 
    // Connect to DB and increment 'i' value
}

This is my C# code in Unity3D:

public IEnumerator test()
{
    WWWForm form = new WWWForm();
    form.AddField("SecretCode", secretcode);
    WWW www = new WWW("http://sitename.com/test.php", form);

    yield return www;

    if(www.text != "")
    {
        // Returned value
    } 
}

Now, if from my game I call the 'test ()' function, the php called check the security code, and if it is right, will increase the variable on the database.

While the game sends this request, Charles Proxy can see the request and therefore I can with Charles resend endlessly the request, increasing endlessly the value in the database.

To make you understand better I'll show you a picture that sums it all:

http://postimg.org/image/x3owvt5il/

Finally there is a way to make invisible the php file or make it look unknown? Or just do not change the value on the database if someone tries to repeat these requests?

展开全部

  • 写回答

1条回答 默认 最新

  • dongwei3866 2015-06-30 09:44
    关注

    SOLUTION: I have found the solution! I'm not very practical in the field of connections between client and server. To protect the communication between the client and the server, just use the HTTPS protocol, and so in addition to having the data already encrypted, you also have the encrypted communication so that nobody can see your url and can not create endless request of the package that you sent previously.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部