Solved

Encrypting data from Java to PHP?

Posted on 2008-10-09
1
294 Views
Last Modified: 2013-12-13
Anyone know of a way to encrypt data, so the data (not just the communication) is encrypted moving from Java to a PHP page via a rest call / web service?

For instance, the java app can encrypt values before building them into a URL, that php can decode:
https://server.com/?value1=QWER&value2=ASDF
etc..
0
Comment
Question by:ecuguru
1 Comment
 
LVL 9

Accepted Solution

by:
mbodewes earned 500 total points
ID: 22694773
Well you could:

Server:
Let PHP script import a previously generated key pair (you only need one key pair)
Let PHP script send base54 encoded public key (public exponent & modulus) using page

Client:
Let Java parse page and load public key pair
Let Java generate a AES secret key
Let Java encrypt the values using the AES key and CBC mode
Let Java encrypt the AES secret key using the previously parsed public key using RSA PKCSv1.5 encryption
Send the GET request with the required encrypted values and an additional value containing the encrypted AES secret key

Server:
Let PHP script retrieve the encrypted values
Let PHP script decrypt the AES secret key using the RSA PKCSv1.5 decryption and the previously generated private key
Let PHP script decrypt the values using the previously decrypted AES secret key

Note that this does not help against man in the middle attack if the receiver of the AES public key cannot validate its origin. It may be better to first distribute this key to the Java side and use this as a static value.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question