Oracle FAQ Your Portal to the Oracle Knowledge Grid
 HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US

Home -> Community -> Mailing Lists -> Oracle-L -> RE: randomly generate unique key

# RE: randomly generate unique key

From: DENNIS WILLIAMS <DWILLIAMS_at_LIFETOUCH.COM>
Date: Fri, 30 May 2003 09:39:46 -0800
Message-ID: <F001.005A712D.20030530093946@fatcity.com>

Joan
Okay, a coworker has experience in this area and provided an education on this that may benefit me some day. He wants 50% royalty.

• Add a check digit to your existing number. This will be an easy solution for you, not requiring much change. The extra digit will foil someone just trying to create their own number by simply incrementing an existing number.
• Here is a simple formula for your check digit. You may choose something simpler or more bulletproof.

Let's say my original number is 123456789. First, I multiply each digit by a weight. Let's say my weight is 137. So I multiply each digit as follows:

```1  2  3  4  5  6  7  8  9 (original number)
1  3  7  1  3  7  1  3  7 (weight)
1  6 21  4 15 42  7 24 63 (product)

```

Now, add each of the digits of the product

1+6+2+1+4+1+5+4+2+7+2+4+6+3 = 48

Now we use a mod operation on the result (48). Usually this is 10 or 11. If we chose mod 10, then our check digit is 8. So our new number is 1234567898.

Dennis Williams
DBA, 80%OCP, 100% DBA
Lifetouch, Inc.
dwilliams_at_lifetouch.com

-----Original Message-----
Sent: Friday, May 30, 2003 10:45 AM
To: Multiple recipients of list ORACLE-L

Hi List,

Originally, Our next generate directory group use sequence # to generate a unique key. (we can't use emplid or social s # as key, since students doesn't have emplid and some foreign students doesn't have ssn). That works fine until the policy changed, they need to publish the unique key which is trunk id. According to the developers, if publish those sequenced unique key, it will create some problems, since the community can guess the next sequence # and got unnecessary info associated with it. Now the question is how to create a random unique key? The idea is create a function call combine the 3 components (date, time, MAC address) to generate a random #. Does the date/time (client query system time)can always be unique or can be duplicated? Does someone has any idea or experience to generate those randomly unique key?

Joan
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Joan Hsieh
INET: joan.hsieh_at_tufts.edu

```Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
```
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: DENNIS WILLIAMS
INET: DWILLIAMS_at_LIFETOUCH.COM
```Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
```
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri May 30 2003 - 12:39:46 CDT

Original text of this message

 HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US