Re: Create on insert a unique random number - Mailing list pgsql-sql

From D'Arcy J.M. Cain
Subject Re: Create on insert a unique random number
Date
Msg-id 20080318153613.364cf08d.darcy@druid.net
Whole thread Raw
In response to Re: Create on insert a unique random number  (Steve Midgley <public@misuse.org>)
Responses Re: Create on insert a unique random number  (Steve Midgley <public@misuse.org>)
List pgsql-sql
On Tue, 18 Mar 2008 12:23:35 -0700
Steve Midgley <public@misuse.org> wrote:
> 1) Create a second field (as someone recommend on this list) that is an 
> MD5 of your primary key. Use that as your "accessor" index from the web 

I strongly disagree for three reasons.  First, if you are going to
generate a key then don't store it.  Just generate it every time.
Second, don't generate it based on a known field.  You may think that
it is secure but what if you private key is compromised?  Do you then
change everyone's security code?  Third, what if one person's
code is compromised?  If it is based on a calculation then you
can't change that one person's security code.

Generate a random number and store that.  You will be much happier when
something goes wrong and something always goes wrong.

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-sql by date:

Previous
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: Create on insert a unique random number
Next
From: "Yusnel Rojas García"
Date:
Subject: pg_dump using SQL