Possible Duplicate:
How Random is System.Guid.NewGuid()?
Based on this question I would like to know if using a GUID to generate a random string of characters and numbers has any flaws in it?
So, for example, if I wanted a random string of characters and numbers of 32 or fewer characters I could use the following C# code:
string s = Guid.NewGuid().ToString().Replace("-", "");
If the length needed to be shorter than 32 I would truncate the string and if it needed to be longer I would add multiple GUID's together.
What are the flaws in this approach?
After I wrote this I realized that one flaw would be that it would only ever have the letters a through f so I will modify the question:
Is this a truly random sequence of 6 characters and 10 digits?
A GUID doesn't make guarantees about randomness, it makes guarantees around uniqueness. If you want randomness, use Random to generate a string.