Reduce url parameters to integer or hexadecimal short

November 19, 2018, at 00:30 AM

i need to make my url shorter . The url give parameters that fill a form with all these values.

I need something like this :

I've tried base64_encode ... but the result is too large. The function md5 , crypt, hash ... are too complex for my needs... There is no need to crypt data, because it's a part of my configuration , just need url shorter.

Important : I do not want to use a database...

EDIT #1 : par1,..,par19 are only letter or integer with for some parameters hexa color, that's all and they instanciate elements in a form. The max string lenght = 10 for a parameter. sometime i only use par1,...par5

I do not want to use POsT in order to avoid page refresh, and i need to send the url to people that work with me...

What i've got :

I've tried to change each letter, number to Ascii but it was not reduced...

Thanks for your answer.

Answer 1

If base64 encoding is still too long then there is not much gain you can get from other encodings as the URI characters you can use without percent-escapes is very limited. And obviously using percent-escapes will make the URL longer instead of shorter, so you'll want to avoid those.

But chances are that you could shorten the length of the non-encoded data. Here are some things you could do:

  • Color codes can represent 224 (~ 16 million) different colors. Are all these colors really a potential candidate for a parameters value? Probably not. You could for instance give up some precision by coding your colors with only 3 hexadecimal characters instead of 6, like can also be done in CSS. Then FFF is equivalent to FFFFFF and 969 is 996699. This still allows for 4000 different colors. If you intend to use only a few different colors, then the following idea could also be used for them:
  • names and other words (like "example", "on", "a", and "backend1") will not be completely random. You would probably never define one of these parameters as "xqzIJ4". Possibly you have a limited set of possible words that can occur in a certain argument. Make a comprehensive list of those and give them a sequential number (1, 2, ...) and pass that number (in hexadecimal notation) instead of the word.
  • Encode integer arguments in hexadecimal too if there is a chance that you need to specify bigger numbers
  • If you can apply the above and use a fixed number of characters for each parameter (pad hexadecimals with zeroes to get a fixed length), then you no longer need the hyphen delimiters. Just concatenate all those codes. When the URL needs to be interpreted, you'll now the length of each argument, and just split the URL in those parts.

Maybe not all of them are acceptable in your case, but even if you can use some, it will shorten your URL. And then you could still consider applying base64 encoding on it to gain a little bit more.

Configure SSL with WAMP 3.1.3

Configure SSL with WAMP 3.1.3

I have used so many guides and question/answers on stackoverflow and across the internet, but somehow I am not able to configure SSL with WAMP using self signed certificate

How to send the variable value to the navigation file in php?

How to send the variable value to the navigation file in php?

I want to send the value to the navigation file before the navigation called in my indexphp

Login form doesn't show error like incorrect password

Login form doesn't show error like incorrect password

I used a script for PTC and I changed the template with another one built with bootstrap, anyway, this login form doesn't work, it show the form but doesn't redirect to any page or show errors if user or password is wrongSorry for my english

Getting Empty Array on Ajax request on INSERT INTO Query, Its working on UPDATE

Getting Empty Array on Ajax request on INSERT INTO Query, Its working on UPDATE

Basically I am not a PHP developer, But I had to do work related to PHP and I am very noob at itThe problem is that I am sending an ajax request to PHP/MYSQL to update the database