June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to create a cryptographically secure, random globally unique identifier (GUID).
Use the RNGCryptoServiceProvider class to create 16 random bytes, and then use these to create a new GUID by passing them to the Guid constructor.
The random GUIDs you create with the Guid.NewGuid method are not known to be cryptographically secure. Thus, it’s theoretically possible for a user to predict a GUID value that you generate for another user or task and use this to exploit weaknesses in your system. To prevent this possibility, you can create a cryptographically secure GUID using the RNGCryptoServiceProvider class. Here’s the code you need:
Public Module RandomGuidGenerator Public Sub Main() ' A ...
Read now
Unlock full access