I’m working on a function to send links to forms, en masse, trough our aplication’s built-in email sender, and I’m planning to just send an url that contains the id and type of the entity it’s been sent to, the id of the form and an identifier telling me in which database to look in (we have more than one databases with client data). I’m looking for a simple way to encode this information.
I thought about just sending an Id and keeping everything in the database, but since these emails will probably be sent en masse for marketting or loyalisation campaigns I think it’s not a good idea.
I googled some encryption functions but the ones I tried sometimes returned results with illegal characters like “?” and “&” which wreck my link.
If you need to encrypt, look for symmetric encryption like AES, then base64 encode the result.
If you only need to encode, then encode by Base64, it’s your best shot.
Not in both cases you need to be aware that some browser URL length or web-server GET support are limited … to some length (between 2000 to 80000 depending on browser and web-server)
Also consider how the link needs to be transmitted. Very long URL are not convenient. You can install very easily yourls.org or similar to shorten your URLs.