Encrypted Data in URLs

I am developing a PHP order management application for a company. To view the order, currently URL /orders/view/3502.

I do not want the order identifier to appear in the URL, so I used the CodeIgniter encryption library to encrypt the identifier in the URL. The URL (after encryption) looks like /orders/view/AaffGdQQ.

The problem I am facing, sometimes in the encrypted identifier, contains a slash or a plus sign that do not work correctly in the URL. CodeIgniter reads the URL based on the slash, so if the encrypted identifier has a slash, it will read it as 2 variables, not one. In addition, plus characters are interpreted as spaces in URLs.

So my question is: how can I encrypt the identifier and make sure that the line does not contain a plus sign or a slash?

EDIT: I had the idea to check if the encrypted identifier contains a slash or plus sign, and if so, encrypt it again. For some reason, every time the identifier is encrypted, it is different, so this will work.

+5
source share
3 answers

You can also base64_encode (). It will also make it much longer and become "safer." Also adds an obfuscation layer.

+8
source

, urlencode() ? CodeIgniter urldecode() .

, !

+1

Look at some characters that encryption does not use or replace as they match. If using URLs, cancel it.

0
source

All Articles