Pass Encrypted Messages Between PHP and Android Part 1

Today we are going to see how we can secure our apps.So for it, we will see how we can Pass Encrypted Messages Between PHP and Android, So our communication between the app and server side will be secure.I am dividing this tutorial into two parts for better understanding.

Encryption

Encryption is the process of changing information in such a way as to make it unreadable by anyone except those possessing special knowledge (usually referred to as a “key”) that allows them to change the information back to its original, readable form.

Step-1 PHP Server Side:

Today I am going to show you how we can secure information over the network using,Advanced Encryption Standard (AES) also known by its original name Rijndael cipher which is one the most famous encryption Algorithm.

In AES there are things which we need to the encrypt our secret message or information first one is the key and the second one is initialization vector. AES cipher has different key sizes 128,192 and 256 but in our case, we are using 128-bit key size. Initialization vector and the key should have the same key size.

Here is the code example:

Demo link:

http://www.phpcodify.com/demo/pass-encrypted-messages-between-php-andandroid/index.php

PHP has already built support for encryption algorithms. As you can see in above example code first we open the Encryption module defines what encryption algorithm we are going to use, then Initialize it with the key and Initialization vector encrypt or decrypt the String then close the module and that’s how it works.

Conclusion:

In the 2nd part on Android Side, we will see how android app gets an encrypted message from PHP and decrypt it on the client side and that’s how commercial apps works.If you find this information useful, remember to share it on your social network. If you have any specific concerns/doubt about this article you can comment below and let us know.

Read previous post:
Pass Data to PHP using AJAX without Page Load

Yesterday I got one request from our blog reader that he want to learn How to Pass Data to PHP using...

Close