|
|
|
|
|
|
|
|
|
Re: Random number generator [message #168059 is a reply to message #167528] |
Tue, 18 April 2006 10:06   |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
Performance wise, I don't know...
Mainly I was just making sure there wasn't something I was missing.
I guess if it isn't needed then I'd leave it out, under the reasoning of "One less thing".
Also dual does seem to be quite fast, I believe it was 10gR1 that had a special optimization for it to not do any logical I/O at all, whereas there would be i/o for dictionary objects.
|
|
|
|
Re: Random number generator [message #168304 is a reply to message #167528] |
Wed, 19 April 2006 12:52   |
markmal
Messages: 113 Registered: April 2006 Location: Toronto, Canada
|
Senior Member |
|
|
If Fred needs "truly random" numbers, may be using of crypto random generators will be better than DBMS_RANDOM.
Using of DBMS_CRYPTO_TOOLKIT or DBMS_CRYPTO is recommended by documentation to get cryptographycally strong randoms.
declare
RN1 number;
RN2 number;
RB RAW(16); l number:=16;
begin
RN1 := DBMS_RANDOM.VALUE;
dbms_output.put_line('DBMS_RANDOM.VALUE :'||RN1);
dbms_crypto_toolkit.Initialize;
dbms_crypto_toolkit.SEEDRANDOM(null,12345312);
RN2 := DBMS_CRYPTO_TOOLKIT.RANDOMNUMBER(null);
dbms_output.put_line('DBMS_CRYPTO_TOOLKIT.RANDOMNUMBER:'||RN2);
RB := DBMS_CRYPTO_TOOLKIT.RANDOMBYTES(null,l);
dbms_output.put_line('DBMS_CRYPTO_TOOLKIT.RANDOMBYTES HEX:'||rawtohex(RB));
RN1 := to_number( rawtohex(RB), rpad('x',l*2,'X'));
dbms_output.put_line('DBMS_CRYPTO_TOOLKIT.RANDOMBYTES NUM:'||RN1);
end;
/
|
|
|
|