Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

simple Android Basic HTTP Auth using PHP! simple Android Basic HTTP Auth using P

ID: 640119 • Letter: S

Question

simple Android Basic HTTP Auth using PHP!

simple Android Basic HTTP Auth using PHP! If someone could please help me with my android app project.

Problem: I'm developing an application that performs a POST request and gets a JSON response from the server (JSON). The problem is, in the server-side, I don't want another app consuming the response, only my app (think like your facebook account, you perform some queries against the server and it returns a json to your facebook app, so you can see the results). The difference is, there is no need for a user to create an account to use the app, anyone can use it. What is the best way to protect the response from the server ?

I'm using php on the server-side (along with mysql) and the response is being returned as a echo json_encode($response)

--------------------

Basically I need help to implement a Basic HTTP Authentication to an existing android app and the php script to process it all on my webserver.

The tabSchedule.java class below uses the json parser class to communicate to a php file on my webserver that outputs json data from my MySQL database

Explanation / Answer

Please test and let me know.. If you have your PHP code ready please let me know. I can help you in android implementation.

Please find the download URL for your code : https://dl.dropboxusercontent.com/u/20998734/EncDecPHPAndroid.zip

Algorithm:

PHP file:

1. Added new API MCrypt class encryption/decryption of string.in PHP using common key

2. Encrypted the JSON text output from PHP.

New Java (MCrypt.java):

1. Added new API MCrypt class encryption/decryption of string.in Java using common key

Android Java (JSONParser.java):

2. Decrypted the JSON text output from PHP.