I’m building an app that works with two main elements.
The first is a segment that generates an entry with a with some hash key (eg. 5c2a4b5773500a0417f6e6d8299776d9cba7ead9) and inserts it into a table.
The second is a url that gets shared (eg. http://myapp.com/a/5c2a4b5773500a0417f6e6d8299776d9cba7ead9) that then comes back to the server, does a lookup against the fore-mentioned table, and executes some sort of predefined action, along with logging the incoming traffic.
Here’s my question:
Doing a lookup with a 40 character length string key seems very resource intensive. Is it perhaps better to encrypt the ID of the row in the DB, thus creating a key, and then decrypt the ‘hash’-key with PHP and do a single row lookup on the DB once it gets back to the server? (Never really needing to store the hash/encrypted keys in the DB)
Where are the pitfalls? Am I using the right terminology? Is there better ways to do this?
Consensus:
Doing lookups with a key on a indexed table column in the DB is
already very efficient albeit 40 characters long.
Avoid PHP from doing any unnecessary heavy lifting.
Try not to keep secrets from SO.com users.