Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have come across the need in my web app to store two values for each user. These values would need to be retrievable from a value stored in a URL. I would prefer to store neither of the values in plaintext.

I've been wondering if there would be a way to use a two-way encryption technique here where I would generate a value to be sent in a URL that would be generated in my app, given to the user, then deleted. The app would then be able to unencrypt the value from within the PHP of the link for the URL.

Any suggestions?

share|improve this question
You mean similar to what the Mega cloud file service does for 'shared' links, embedding the symmetric encryption key into the URL? – Kitsune Apr 8 '13 at 1:33
@Kitsune That's kind of what I was thinking, does it have any security implications? I'm not expert on the subject. – Undo Apr 8 '13 at 2:04
Why in the URL rather than a cookie? So it can be shared? I assume you will be using HTTPS. Some of the replies to about URLs being recorded in logs etc. might be relevant. – armb Apr 8 '13 at 12:32
The URL would need to be shared – Undo Apr 8 '13 at 13:02
up vote 2 down vote accepted

The question to ask is: should the server be able to access the value ?

If the server must be able to access the value, then the "encryption for storage" is just an illusion. An attacker who gains control of the server will be able to read the values, since such an attacker can do whatever the server can do. You might want to apply some "encryption" on the database itself if you consider the database to be "less secure" (or "distinctly secure") than the server (i.e. you envision an attacker who gets a read-only peek at the database, e.g. by stealing a backup tape); in that case, you'd better apply a whole-database encryption system, which will be more comprehensive, simpler, and more efficient, than simply concentrating on your two values (in Microsoft's SQL Server, this is called Transparent Data Encryption).

If the server must not be able to access the value, then the client application must do the encryption and decryption -- which raises the issue of key management. The client application must have a user-specific key which it stores and then uses to decrypt and encrypt the data. There is ample room for blunders here, so you'd better choose a well-vetted protocol and format for that. One way is to encrypt the data with a key derived from a user password; the OpenPGP format has some support for that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.