You may use this,
RNGCryptoServiceProvider Class (System.Security.Cryptography)[
^] and it provides a secure random — not a seeded random number. In most secure cases this is the random number generator that should be used instead of the plain old Random class of the .NET framework. You can read more about this object on the MSDN page itself.
Update:
If you are using the token only for the sake of authentication, like OAuth etc. Then I would recommend using the Guid object, to create a new unique string for every device. It has a size of 128 bits (2
128 + 1) is a huge amount. You can generate that quite easily as well,
var token = Guid.NewGuid().ToString();
Then this can be stored and used wherever needed. I used this method in my own application. The secure and cryptic way of generating a token would be useful in cases where everything needs to be private — cash management is one of the examples here, encryption/decryption or generating the secure keys or salts for password hashing.
For more on this, please see:
Guid Structure (System)[
^]