Solved

Encrypt in javascript then decrypt in php

Posted on 2006-10-22
5
1,729 Views
Last Modified: 2012-06-27
I'm trying to find a way to encrypt something in javascript and decrypt it in php. anyone come across something like this. Thanks!
0
Comment
Question by:ocsurf
[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 Comments
 
LVL 19

Assisted Solution

by:BrianGEFF719
BrianGEFF719 earned 250 total points
ID: 17785704
Hi ocsurf,
Here is the problem with that, you're going to have to embed some type of encryption key in the javascript routine which will make decrypting the same text rather trivial by anyone. Have you considered a hash?

For example if this is a password related issue, you can MD5 the password, send it to the server and compare to the password in a database that is also md5 hashed. Make sense? Which is completely irreversible.

-Brian
0
 
LVL 1

Author Comment

by:ocsurf
ID: 17785790
Yea i thought and tried that. but the problem is we are logging into a ldap server and don't have access to the passwords.
0
 
LVL 18

Accepted Solution

by:
Mark Gilbert earned 250 total points
ID: 17785795
As brian said, anything in javascript will be seen by the user.  Simple fact.  If you are looking for php encryption then there are lots of samples of code that could be used.  There are dozens of freely available scripts out there, however, they are all opensource, and chances are they could be decrypted.  However, it also depends on how secure your site is.  If you utilize ssl, along with authentication and encryption then you should be looking at a pretty sound, but not perfect system to rely on.  Always patch your code, and operating system along the way to ensure integrity of the data.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 17785828
There is really no secure way to encrypt data on client side.
0
 
LVL 16

Expert Comment

by:ellandrd
ID: 17788003
Do you really need to encrypt in javascript?  

Without knowing the specifics of your task, may i suggest that you enter the string that you want encrypted into a html form, then using the POST method, send it to a php page for encryption and comparison against your reference encrypted string.

This method would keep prying eyes out of your encryption process, as it would be handled via your php script.

Remember, it is possible to automatically send forms if this is what you'd like to do.

If you can clarify your task, then i can perhaps help further..
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 …

690 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