For security reasons, I looking to find out if it is possible to encrypt a string using the JavaScript at the client side and then decrypt the same script using PHP on the server side! Can anybody help me in this.
For security reasons, I looking to find out if it is possible to encrypt a string using the JavaScript at the client side and then decrypt the same script using PHP on the server side! Can anybody help me in this.
How do you want to encrypt it, with a private key or with completely different complex programming?
I feel encrypting with the private key will be sufficient. This private key can be generated by the server at its side, so that decryption would be possible.
ScrEnc is one such thing that will provide for encryption in JavaScript.
ScrEnc provides tools to encrypt your JavaScript/JScript, C/C++/MFC scripts before posting them online, or for distribution, preserving full functionality of the script but making them very hard to read. ScrEnc can also decrypt previously encrypted scripts into fully readable source code files, including files encrypted with Windows Script Encoder. ScrEnc also provides other useful features designed to facilitate your code scripts development such as conversion of Windows to Unix text file formats.
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.
It seemed to me a little more complicated than that as when i origionally had and used the above the string of random characters were not anything like It%27s%20me%21
u could not read any words it was all completely encrypted or scrambled or something
any ideas??
If you want to encrypt in JS and decrypt in PHP, you'll have to start by finding a matching algorithm between the two. Take a look at PHP's mcrypt functions and find a compatible JS algorithm. I personally looked at using the AES script execute posted at one time; it uses the CTR (counter) method, and as luck would have it, PHP's mcrypt extension can utilize CTR and rijndael-N (AES) encryption. I never did complete the project though.
Of the three posted, DES might be the easiest to make work, although not the most secure. Security is relative when you're talking about anything on the web anyway
Bookmarks