<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Eddie Awad’s Blog - Latest Comments in Random string generator</title><link>http://awads.disqus.com/</link><description>News, views, tips and tricks on Oracle and other fun stuff</description><atom:link href="https://awads.disqus.com/random_string_generator/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 22 Nov 2005 15:52:03 -0000</lastBuildDate><item><title>Re: Random string generator</title><link>http://awads.net/wp/2005/07/28/random-string-generator/#comment-3657765</link><description>&lt;p&gt;edcas, the seed is needed to generate the random number or string. The seed can be a number or a string. If you do not initialize the generator by explicitly calling the seed procedure, a default seed is used, in that case, it is equal to:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;TO_CHAR(SYSDATE,'MM-DD-YYYY HH24:MI:SS') ||&lt;br&gt;USER || USERENV('SESSIONID')&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;So, if you do not seed, and then call dbms_random.value, chances are you will not get the same random value.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The dbms_random package specification says: &lt;em&gt;If this package is seeded twice with the same seed, then accessed in the same way, it will produce the same results in both cases.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;So, your observation is correct, given the same seed over and over again, you will get the same result each time you execute the same dbms_random procedure.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;How can a seed be used? well, one example is when you want to generate a random password. You would seed the generator with the username, so distinct usernames will have distinct random passwords, but same usernames will have the same random password since the seed (username) is the same.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Tue, 22 Nov 2005 15:52:03 -0000</pubDate></item><item><title>Re: Random string generator</title><link>http://awads.net/wp/2005/07/28/random-string-generator/#comment-3657766</link><description>&lt;p&gt;Hi Eddie,&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I can't really figure out what's the use for SEED procedure here. Can you explain further? &lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;As I execute the code below, it give me the same result.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;BEGIN&lt;br&gt;dbms_random.seed(1234535678);&lt;br&gt;dbms_output.put_line('Random1: '||dbms_random.value);&lt;br&gt;END;&lt;br&gt;&lt;br&gt;Random1: .62004818671882084550610341425311827476&lt;br&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">edcas</dc:creator><pubDate>Tue, 22 Nov 2005 02:50:37 -0000</pubDate></item><item><title>Re: Random string generator</title><link>http://awads.net/wp/2005/07/28/random-string-generator/#comment-3657764</link><description>&lt;p&gt;Robert,&lt;br&gt;I could not understand your problem. However, here are some clarifications about the package &lt;code&gt;DBMS_RANDOM&lt;/code&gt; which I'm sure you already know, but does not hurt to add them here for future reference:&lt;/p&gt;&lt;p&gt;The package &lt;code&gt;DBMS\_RANDOM&lt;/code&gt; is only available in Oracle version 8 and above.&lt;/p&gt;&lt;p&gt;If you want to encrypt sensitive data, then you should use the built-in package &lt;code&gt;DBMS\_OBFUSCATION\_TOOLKIT&lt;/code&gt;, not &lt;code&gt;DBMS\_RANDOM&lt;/code&gt; .&lt;/p&gt;&lt;p&gt;For an analysis of &lt;code&gt;DBMS\_RANDOM&lt;/code&gt;, how it works and the quality of the generated random numbers or strings, I suggest &lt;a href="http://www.dbasupport.com/oracle/ora9i/unwrappingDBMS01_01.shtml" rel="nofollow noopener" target="_blank" title="http://www.dbasupport.com/oracle/ora9i/unwrappingDBMS01_01.shtml"&gt;this&lt;/a&gt; article.&lt;/p&gt;&lt;p&gt;The following functions are not documented in &lt;a href="http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a76936/dbms_ra2.htm" rel="nofollow noopener" target="_blank" title="http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a76936/dbms_ra2.htm"&gt;Oracle 8i&lt;/a&gt; and &lt;a href="http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_rando2.htm" rel="nofollow noopener" target="_blank" title="http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_rando2.htm"&gt;Oracle 9i&lt;/a&gt; &lt;code&gt;DBMS\_RANDOM&lt;/code&gt;'s documentation, but they are in &lt;a href="http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10802/d_random.htm#ARPLS040" rel="nofollow noopener" target="_blank" title="http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10802/d_random.htm#ARPLS040"&gt;Oracle 10g&lt;/a&gt;'s: &lt;code&gt;NORMAL&lt;/code&gt;, &lt;code&gt;VALUE&lt;/code&gt; and &lt;code&gt;STRING&lt;/code&gt;. A look at the source code of &lt;code&gt;DBMS\_RANDOM&lt;/code&gt; reveals these hidden and useful functions.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Fri, 29 Jul 2005 14:38:38 -0000</pubDate></item><item><title>Re: Random string generator</title><link>http://awads.net/wp/2005/07/28/random-string-generator/#comment-3657763</link><description>&lt;p&gt;Speaking of random numbers, what do you think about this problem of mine:&lt;/p&gt;&lt;p&gt;&lt;a href="http://thinkoracle.blogspot.com/2005/05/random-numbers.html" rel="nofollow noopener" target="_blank" title="http://thinkoracle.blogspot.com/2005/05/random-numbers.html"&gt;http://thinkoracle.blogspot...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Robert Vollman</dc:creator><pubDate>Fri, 29 Jul 2005 11:47:50 -0000</pubDate></item></channel></rss>