Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would caution that GUIDs are <strong>not random numbers</strong>. They should not be used as the basis to generate anything that you expect to be totally random (see <a href="http://en.wikipedia.org/wiki/Globally_Unique_Identifier" rel="noreferrer">http://en.wikipedia.org/wiki/Globally_Unique_Identifier</a>):</p> <blockquote> <p>Cryptanalysis of the WinAPI GUID generator shows that, since the sequence of V4 GUIDs is pseudo-random, given the initial state one can predict up to next 250 000 GUIDs returned by the function UuidCreate. This is why GUIDs should not be used in cryptography, e. g., as random keys.</p> </blockquote> <p>Instead, just use the C# Random method. Something like this (<a href="http://www.c-sharpcorner.com/UploadFile/mahesh/RandomNumber11232005010428AM/RandomNumber.aspx" rel="noreferrer">code found here</a>):</p> <pre><code>private string RandomString(int size) { StringBuilder builder = new StringBuilder(); Random random = new Random(); char ch ; for(int i=0; i&lt;size; i++) { ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; builder.Append(ch); } return builder.ToString(); } </code></pre> <p>GUIDs are fine if you want something <strong>unique</strong> (like a unique filename or key in a database), but they are not good for something you want to be <strong>random</strong> (like a password or encryption key). So it depends on your application.</p> <p><strong>Edit</strong>. Microsoft says that Random is not that great either (<a href="http://msdn.microsoft.com/en-us/library/system.random(VS.71).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.random(VS.71).aspx</a>):</p> <blockquote> <p>To generate a cryptographically secure random number suitable for creating a random password, for example, use a class derived from System.Security.Cryptography.RandomNumberGenerator such as System.Security.Cryptography.RNGCryptoServiceProvider.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload