Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

encrypt javascript code in des with public key and decrypt it in php with private key

Posted on 2013-07-01
7
Medium Priority
?
1,867 Views
Last Modified: 2013-07-25
i want to DES encrypt javascript code and want to decrypt it in server side using php with a private key.

Please suggest me how to implement this.
0
Comment
Question by:chrisvee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
7 Comments
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39291333
You want to encrypt the Javascript code itself using PHP and then decrypt the code later using PHP again?

Or are you saying you want to use Javascript to encrypt a value and then use PHP to decrypt it?

Any reason you want to use DES specifically?
0
 

Author Comment

by:chrisvee
ID: 39291356
yes. i want to use Javascript to encrypt a value and then use PHP to decrypt it.

base64 method can be easily decoded. so thats why i am planning to use DES.
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 1200 total points
ID: 39291360
Also, you mentioned "private key" - are you talking about using public/private key encryption (asymmetric) or symmetric?

Asymmetric is when you have a public certificate that does the encryption and a private key that does the decryption.

Symmetric is when you encrypt and decrypt data using the same password. DES is a cipher that's used in symmetric cryptography, not in asymmetric (at least not to my knowledge).

For Javascript crypto, I'd suggest this library:
https://code.google.com/p/jscryptolib/

For PHP crypt, use mcrypt:
http://php.net/manual/en/book.mcrypt.php
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39291367
Base64 is not encryption - that is encoding. There is no security around base64. If you don't have a specific need for DES, I would suggest using AES encryption. It's a more common cipher, so you'll have better luck finding specific examples in the future, and you can start with AES-128 and move up to AES-256 if you want even stronger security.
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39291409
Sorry, I linked to the wrong Javascript library. I was trying to link to CryptoJS, not JSCrypto:
https://code.google.com/p/crypto-js/#AES

That should show you the code to encrypt the value in AES (you may need to base64-encode the encrypted value afterwards so that it works with other requests).

The decryption routine can be found here:
http://php.net/manual/en/function.mcrypt-decrypt.php
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 300 total points
ID: 39291661
If you are doing this to prevent eavesdropping, SSL/TLS cert and HTTPS is a better way.  That way, any eavedropper won't even know there is something to be encrypted in your response because it is All encrypted.
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39354946
Is there a reason for the B grade instead of the A grade? I gave you exactly what you were asking for...
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

636 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