?
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,808 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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