
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Storing Data Securely
|
971
Discussion
Random provides methods like Next, NextBytes, and NextDouble to generate random
information for integers, arrays of bytes, and doubles, respectively. These methods
can produce a moderate level of unpredictability, but to truly generate a more unpre-
dictable random series, you need to use the
RNGCryptoServiceProvider.
RNGCryptoServiceProvider can be customized to use any of the underlying Win32
Crypto API providers. You pass a
CspParameters class in the constructor to deter-
mine exactly which provider is responsible for generating the random byte sequence.
CspParameters allows you to customize items such as the key container name, the
provider type code, the provider name, and the key number used.
The
GetBytes method populates the entire length of the byte array with random
bytes.
See Also
See the “RNGCryptoServiceProvider Class,” “CspParameters Class,” and “Crypto-
graphic Provider Types” topics in the MSDN documentation.
17.8 Storing Data Securely
Problem
You need to store settings data about individual users for use by your application
and keep this data isolated from other instances of your application run by different
users.
Solution
You can use isolated storage to establish per-user data stores for your application
data and then use hashed values for ...