Question

When I use some of php's encryption functions, I end up getting a few characters I don't want (+, /, =). The problem is that my application doesn't allow these in the url. I'm wondering if there's a good way of encrypting an integer and having only alphanumeric characters in the result? I'm trying to pass some data through the url. I know it's possible to do some workarounds (put data in database and pass the id to the row or something), but I really want to try it this way.

Ideas?

Was it helpful?

Solution

I would rethink your problem. You never, ever want to pass sensitive data in the URL query. There is already a mechanism for collecting sensitive data over the web - it's called SSL. If you need to get sensitive data from the user, accept it as POST data and use SSL.

If you absolutely must do this (don't), you would do it by base64'ing the encrypted message and being very careful about key safety.

OTHER TIPS

You're looking for base_convert().

I believe base64_encode then send data and then base64_decode the other side.

I "think" base64 encoding is perfectly file for URI's

I use sh1 and never got nothing but numbers and letter's...

http://www.php.net/manual/en/function.sha1.php

Maybe it's your solution...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top