# .NET Cryptography Model

### Object Inheritance <a href="#object-inheritance" id="object-inheritance"></a>

The .NET Framework security system implements an extensible pattern of derived class inheritance. The hierarchy is as follows:

* Algorithm type class, such as _SymmetricAlgorithm_, _AsymmetricAlgorithm_ or _HashAlgorithm_. This level is abstract.
* Algorithm class that inherits from an algorithm type class; for example, _Aes_, _RC2_, or _ECDiffieHellman_. This level is abstract.
* Implementation of an algorithm class that inherits from an algorithm class; for example, _AesManaged_, _RC2CryptoServiceProvider_, or _ECDiffieHellmanCng_. This level is fully implemented.

### Choosing an Algorithm <a href="#choosing-an-algorithm" id="choosing-an-algorithm"></a>

You can select an algorithm for different reasons: for example, for data integrity, for data privacy, or to generate a key. Symmetric and hash algorithms are intended for protecting data for either integrity reasons (protect from change) or privacy reasons (protect from viewing). Hash algorithms are used primarily for data integrity.

Here is a list of recommended algorithms by application:

* **Data privacy**:
  * Aes
* **Data integrity**:
  * HMACSHA256
  * HMACSHA512
* **Digital signature**:
  * ECDsa
  * RSA
* **Key exchange**:
  * ECDiffieHellman
  * RSA
* **Random number generation**:
  * RNGCryptoServiceProvider
* **Generating a key from a password**:
  * Rfc2898DeriveBytes
