Results 1 to 7 of 7

Thread: Encryption in JavaScript, Decryption in PHP

  1. #1
    Join Date
    Oct 2008
    Posts
    76

    Encryption in JavaScript, Decryption in PHP

    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521
    How do you want to encrypt it, with a private key or with completely different complex programming?

  3. #3
    Join Date
    Oct 2008
    Posts
    76
    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005
    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.

  5. #5
    Join Date
    May 2008
    Posts
    2,297
    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.

  6. #6
    Join Date
    Oct 2008
    Posts
    76
    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??

  7. #7
    Join Date
    Feb 2008
    Posts
    1,852
    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

Similar Threads

  1. Replies: 3
    Last Post: 03-01-2011, 09:11 AM
  2. DES encryption and decryption using C or Java
    By sayanmaji in forum Software Development
    Replies: 5
    Last Post: 26-11-2010, 03:20 AM
  3. XML encryption and decryption
    By Anirvinya in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 03:31 AM
  4. Do you know difference between encryption and decryption?
    By rooki in forum Networking & Security
    Replies: 4
    Last Post: 30-11-2009, 12:24 PM
  5. Replies: 2
    Last Post: 22-02-2006, 03:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,629,955.86501 seconds with 17 queries