News for hackers. Stuff that matters.
Re:Obfuscate Your Company by edw519 on Friday May 29, 2009 @06:47PM (#632997)
"omits the point that strings are way more expensive to look up than integers"

So what? We're talking microseconds.

I take it a step further than OP. Every data base record has 2 IDs, an internal sequential one and an external one. The external one is cross-referenced to the internal one, which is never seen by human eyes. So every read is actually 2 reads, which is way more expensive still. I have been doing this for years and have never seen any noticeable degradation.

The reason I started this has nothing to do with security. It's so that I can change any key on any data base at any time without actually changing the primary key and without a conversion. (You'd be surprised how often you need to do this in commercial applications.)

Re:Obfuscate Your Company by dpifke on Friday May 29, 2009 @07:01PM (#633012)
Using database OIDs as publicly accessible identifiers is a neat idea, one I haven't tried.

Looking at the Postgres docs (http://www.postgresql.org/docs/8.0/static/datatype-oid.html) they discourage the use of OIDs, going so far as to say the default in future versions is not to create OIDs for user-created tables.

Also, this would mean that a dump/restore of your database results in invalidating all your identifiers.

What RDBMS do you do this on and have you run into any problems?

EDIT: Sure enough, in modern Postgres, these are disabled by default. Additionally, they appear to be sequentially assigned:

dev01=> select *,oid from test; test_id | test_string | oid ---------+-----------------+------- 1 | blah | 29837 2 | blahblahblah | 29838 3 | xxxblahblahblah | 29839

Re:Obfuscate Your Company by edw519 on Friday May 29, 2009 @07:17PM (#633031)
I implement double IDs in my own code, not in any built-in function of any DBMS. You're right to be suspicious.
Re:Obfuscate Your Company by jasonkester on Saturday May 30, 2009 @10:06AM (#633641)
You can get around this by simply having a 2nd way to reference that single integer ID.

I've built systems in the past where we simply gave out base26Encode(ID+20000) whenever an ID was desplayed on the URL, which gives a nice typeable 4-digit string like "6cw8". Pulling up a record, you'd simply check whether you were looking at an integer and if not, (base26Decode(key)-20000) and you're in business.

It doesn't need to be rocket science crypto stuff. After all, it's just obfuscation to confuse the casual observer.