1

I have a url with several parameters is use for a http request. It looks like this:

http://www.url.com/site.php?parameter1=x&parameter2=y 

I would like to make sth like this in javascript:

http://www.url.com/data=wafseghsgse or http://www.url.com/site/?data=wafseghsgse 

And in php I would get the "old" url back to work with it.

I am looking for the fastest way to do this, not the most secure one. To save a key for encryption I would use the database or maybe session (safe?).

Looking for your great ideas.

Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70
Ruven JR. Maerson
  • 309
  • 1
  • 6
  • 16
  • You are looking to build a URL shortener. There is plenty of information about how to build one out there. Related: [URL Shortening Site](http://stackoverflow.com/q/1383145) and [URL shortener: best encoding method?](http://stackoverflow.com/q/2375968) – Pekka Oct 31 '12 at 09:27
  • @quentin because i do not like the user to see the parameter sent maybe user_id etc. – Ruven JR. Maerson Oct 31 '12 at 09:29
  • Will you send the key to the browser for encryption? – Salman A Oct 31 '12 at 09:30
  • @Salman. No i would get it from db or store it in session. Last one i do not have any clue if it is save or not. – Ruven JR. Maerson Oct 31 '12 at 09:33
  • Encrypting something using javascript on the clients browser will not make you application secure. – ynh Oct 31 '12 at 09:33
  • @RuvenJR.Maerson — If you are encrypting the data with client side JavaScript, then the unencrypted version *must* be available to the client, so the user can see it. Attempting to keep these things secret is fruitless and adds unnecessary complexity that can add bugs. – Quentin Oct 31 '12 at 09:35

1 Answers1

0

If you just want a fast obfuscate method with no care about security, you can use ROT13, you have javascript ROT13 implementations in Where is my one-line implementation of rot13 in JavaScript going wrong? and then in PHP you have str_rot13() to decrypt the javascript version.

Community
  • 1
  • 1
Nelson
  • 49,283
  • 8
  • 68
  • 81