drwj4061 2014-08-18 05:05
浏览 60
已采纳

保护android和php之间的连接

I am developing an android app where the user can signup using the android Facebook SDK. I am using Google Volley library to make http requests to my PHP page to receive JSON data from MySql database. I want to store personal information about the user and retrieve them later from the database. I spent the entire day looking on Google ways on how to secure android-php connection. One of the most popular solution I came across is send a hash key with the post request and verify that hash key via PHP. Like so:

if($_POST['secret'] != '3CH6knCsYmvA2fdghfdfgmf3JqmUctCM') {
    header('HTTP/1.1 403 Forbidden');
    error_log("ERROR: wrong secret: " . $_POST['secret']);
    exit("Access denied");
}

The problem with the code above is that some hackers can de-compile any apk file and look at the code and easily figure out what they key hash is. Since I don't have an custom login system with username and password to authenticate the user, what can I use to secure the connection between android and php? I need an example or a link to a tutorial or any suggestion about established solutions to such problem.

This question isn't new on Stack Overflow, but other similar questions are 2 or 3 years old which is considered historic in the rapid development world of Android.

  • 写回答

1条回答 默认 最新

  • douxun4173 2014-08-18 05:09
    关注

    Securing the connection between the server and the app? Just use Https. Now if you want to make it so only your app can access that web service- there needs to be some kind of secret shared between them to check. Normally this is a password, entered by the user. The fact the user enters it secures your app from hacking, as the info isn't in the app. If you aren't going to have the user enter it, then it needs to be in your app. Which means any hacker who really wants it will get it. You can obscure it a little bit, but they will find it eventually.

    Basically, to ensure that it can't be reverse engineered you need the user and a full login system.

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类