<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx</link><description>Random number generators written in code (or any deterministic algorithm) aren&amp;#39;t really random. You could go as far as to say that unless based on nondeterministic events at a quantum level, there will (theoretically) be a way of predicting the next</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#7159276</link><pubDate>Sat, 01 Aug 2009 09:46:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7159276</guid><dc:creator>kame</dc:creator><author>kame</author><description>&lt;p&gt;p a prime modulus, where 2L–1 &amp;lt; p &amp;lt; 2L, and L is the bit length of p. Values for L are&lt;/p&gt;
&lt;p&gt;provided in Section 4.2.&lt;/p&gt;
&lt;p&gt;q a prime divisor of (p – 1), where 2N–1 &amp;lt; q &amp;lt; 2 N, and N is the bit length of q. Values for&lt;/p&gt;
&lt;p&gt;are provided in Section 4.2.&lt;/p&gt;
&lt;p&gt;g a generator of the subgroup of order q mod p, such that 1 &amp;lt; g &amp;lt; p.&lt;/p&gt;
&lt;p&gt;x the private key that must remain secret; x is a randomly or pseudorandomly generated&lt;/p&gt;
&lt;p&gt;integer, such that 0 &amp;lt; x &amp;lt; q, i.e., x is in the range [1, q–1].&lt;/p&gt;
&lt;p&gt;y the public key, where y = gx mod p.&lt;/p&gt;
&lt;p&gt;k a secret number that is unique to each message; k is a randomly or pseudorandomly&lt;/p&gt;
&lt;p&gt;generated integer, such that 0 &amp;lt; k &amp;lt; q, i.e., k is in the range [1, q–1].&lt;/p&gt;
&lt;p&gt;r = (gk mod p) mod q.&lt;/p&gt;
&lt;p&gt;z = the leftmost min(N, outlen) bits of Hash(M).&lt;/p&gt;
&lt;p&gt;s = ( k −1 (z + xr)) mod q.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7159276" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#6676987</link><pubDate>Mon, 13 Oct 2008 08:01:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6676987</guid><dc:creator>akhil</dc:creator><author>akhil</author><description>&lt;p&gt;hi&lt;/p&gt;
&lt;p&gt;i m doing in an online Examinition Project in C# Dot Net 2005.I want to call all questions (Unique) randomly from SQL server.&lt;/p&gt;
&lt;p&gt;Can u help me to solve my problem.&lt;/p&gt;
&lt;p&gt;Plz Help.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6676987" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#6349547</link><pubDate>Wed, 02 Jul 2008 09:04:04 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6349547</guid><dc:creator>Balamurugan</dc:creator><author>Balamurugan</author><description>&lt;p&gt;I have to generate random numbers,its should not be repeated...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6349547" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#5471636</link><pubDate>Wed, 19 Dec 2007 06:10:25 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5471636</guid><dc:creator>Free News Website</dc:creator><author>Free News Website</author><description>&lt;p&gt;Appreciate the article. What's the best way to generate the seed? I was thinking of using CPU ticks.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5471636" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#3459269</link><pubDate>Fri, 10 Aug 2007 16:01:35 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3459269</guid><dc:creator>Yining Chen</dc:creator><author>Yining Chen</author><description>&lt;p&gt;why not just use a singleton pattern to wrap around the Random class? that'll solve all your concurrency issues, as well as giving you a global RNG.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3459269" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#3251366</link><pubDate>Sun, 22 Jul 2007 18:56:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3251366</guid><dc:creator>Sultan Saadat</dc:creator><author>Sultan Saadat</author><description>&lt;p&gt;Simplest way&lt;/p&gt;
&lt;p&gt;private int RandomNumber(int min, int max)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;Random random = new Random();&lt;/p&gt;
&lt;p&gt;return random.Next(min, max); &lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3251366" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#2690030</link><pubDate>Wed, 30 May 2007 10:07:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2690030</guid><dc:creator>roflmao</dc:creator><author>roflmao</author><description>&lt;p&gt;hbajksdhajksdh&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2690030" width="1" height="1"&gt;</description></item><item><title>This is like, so random! Some Randomness from System.Random</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#391169</link><pubDate>Wed, 09 Mar 2005 21:02:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:391169</guid><dc:creator>TrackBack</dc:creator><author>TrackBack</author><description>&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=391169" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#127546</link><pubDate>Thu, 06 May 2004 23:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:127546</guid><dc:creator>Daniel Jin</dc:creator><author>Daniel Jin</author><description>that solves one problem.  in your code, you would also run into a race condition in the Random class instantiation.  Two threads, concurrently, could check the cache before an instance is created, both will retrieve *null*, both will create new instances ... you would need to synchronize that too.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=127546" width="1" height="1"&gt;</description></item><item><title>re: Random Numbers in C#</title><link>http://weblogs.asp.net/erobillard/archive/2004/05/06/Random-Numbers-in-C_2300_.aspx#127427</link><pubDate>Thu, 06 May 2004 20:41:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:127427</guid><dc:creator>Eli Robillard</dc:creator><author>Eli Robillard</author><description>Daniel: Good point, I've added a lock {} as recommended by Brad Abrams' blog. &lt;br&gt;&lt;br&gt;Ryan: Another point recommended by Brad, though that class is an abstract which is intended to be inherited by other implementations, it can't be used directly. The remarks in the docs offer this: &amp;quot;For an implementation of a cryptographic random number generator, use the derived class RNGCryptoServiceProvider.&amp;quot; &lt;br&gt;&lt;br&gt;As a solution, it seems to me somewhere between overkill and passing the buck. But, for those so inclined: &lt;a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographyrngcryptoserviceproviderclasstopic.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographyrngcryptoserviceproviderclasstopic.asp&lt;/a&gt;&lt;br&gt;&lt;br&gt;Great comments!&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=127427" width="1" height="1"&gt;</description></item></channel></rss>