Php – URL Encryption vs. Encoding

efficiencyencryptionPHPprogramming practicestext-encoding

At the moment non/semi sensitive information is sent from one page to another via GET on our web application. Such as user ID or page number requested etc. Sometimes slightly more sensitive information is passed such as account type, user privileges etc.

[EDIT: I may have worded this wrong, I'm not passing sessionID or actual user privileges, just simple NON-sensitive data – I just don't want the user to see the words easily, does not matter if a more technical user can read it as they cannot do any damage and cause security concerns. read the chat with @delnan]

We currently use base64_encode() and base64_decode() just to de-humanise the information so the end user is not concerned.

Is it good practice or common place for a URL GET to be encrypted rather than simply PHP base64_encoded?

Perhaps using something like, this:

$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");

Is this too much or too power hungry for something as common as the URL GET.

Best Answer

Why are you using GET in the first place? Just POST the sensitive data over HTTPS, and add suitable CSRF protection.

This is assuming that the information is sensitive in the sense that the authorized user and the server may see it, but others (other users and attackers) must not.

If the user isn't allowed to see the information either, then just don't send it in the first place. Keep it on the server; if you need to link it to the user, pass a session ID back and forth (with the usualy precautions and safeguards in place), and store the sensitive information in the session (that is, server-side).

Sending sensitive information to an unauthorized client is sloppy, because it gives the attacker an opportunity for off-line cracking methods.