Received: from mail.flutterby.com (www.flutterby.com [209.140.49.28]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3GKTmu82564 for ; Mon, 16 Apr 2001 16:29:49 -0400 (EDT) (envelope-from danlyke@flutterby.com) Received: from wynand.flutterby.com (adsl-64-163-66-178.dsl.snfc21.pacbell.net [64.163.66.178]) by www.flutterby.com (8.12.0.Beta7/8.12.0.Beta7/Debian 8.12.0-1) with ESMTP id f3GKbCsK017610 for ; Mon, 16 Apr 2001 13:37:12 -0700 Received: (from danlyke@localhost) by wynand.flutterby.com (8.9.3/8.9.3/Debian 8.9.3-21) id NAA00539; Mon, 16 Apr 2001 13:16:44 -0700 From: Dan Lyke MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15067.21277.884548.721903@wynand.flutterby.com> Date: Mon, 16 Apr 2001 13:16:29 -0700 (PDT) To: pgsql-sql@postgresql.org Subject: Using Random Sequence as Key In-Reply-To: <9bdjag$faj$1@news.tht.net> References: <9bdjag$faj$1@news.tht.net> X-Mailer: VM 6.72 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid X-Archive-Number: 200104/256 X-Sequence-Number: 2606 Bernardo de Barros Franco writes: > Hello, I was wondering if noone can help me maybe someone could at least > give me some directions where to look for info or where to ask: > I wanted to index a table by a random key. As others have pointed out, making a unique random primary key is tough. What I do for my cookie on my web based login system is have two fields in my database, one's the "id SERIAL", the other is a "magiccookie CHAR(16)" which I populate with 16 random characters on the initial insert. My cookie is then of the format "id/magiccookie". In my login verification code I split on the "/" character and query on "WHERE id=$id AND magiccookie=$magiccooke". Even though the "id" field is encoded in the cookie in plain text a cracker can't just guess at the user id number because that 16 character magiccookie needs to match as well. This also lets me be pretty loose about the id information, I can use it in other public places, because only the magiccookie needs to be restricted to being known by the logged in user. Dan