# AesCng Class

## Definition

Provides a Cryptography Next Generation (CNG) implementation of the Advanced Encryption Standard (AES) algorithm.

`public ref class AesCng sealed : System::Security::Cryptography::Aes`

`public sealed class AesCng : System.Security.Cryptography.Aes`

```
type AesCng = class
inherit Aes
```

```
Public NotInheritable Class AesCng
Inherits Aes
```

- Inheritance

## Constructors

AesCng() |
Initializes a new instance of the AesCng class with an ephemeral key. |

AesCng(String) |
Initializes a new instance of the AesCng class with the specified key name, which represents an existing persisted AES key. |

AesCng(String, CngProvider) |
Initializes a new instance of the AesCng class with the specified key name, which represents an existing persisted AES key, and the specified key storage provider (KSP). |

AesCng(String, CngProvider, CngKeyOpenOptions) |
Initializes a new instance of the AesCng class with the specified key name, which represents an existing persisted AES key, the specified key storage provider (KSP) and key open options. |

## Fields

BlockSizeValue |
Represents the block size, in bits, of the cryptographic operation. (Inherited from SymmetricAlgorithm) |

FeedbackSizeValue |
Represents the feedback size, in bits, of the cryptographic operation. (Inherited from SymmetricAlgorithm) |

IVValue |
Represents the initialization vector (IV) for the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

KeySizeValue |
Represents the size, in bits, of the secret key used by the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

KeyValue |
Represents the secret key for the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

LegalBlockSizesValue |
Specifies the block sizes, in bits, that are supported by the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

LegalKeySizesValue |
Specifies the key sizes, in bits, that are supported by the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

ModeValue |
Represents the cipher mode used in the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

PaddingValue |
Represents the padding mode used in the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

## Properties

BlockSize |
Gets or sets the block size, in bits, of the cryptographic operation. (Inherited from SymmetricAlgorithm) |

FeedbackSize |
Gets or sets the feedback size, in bits, of the cryptographic operation for the Cipher Feedback (CFB) and Output Feedback (OFB) cipher modes. (Inherited from SymmetricAlgorithm) |

IV |
Gets or sets the initialization vector (IV) for the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

Key |
Gets or sets the key for the AesCng algorithm. |

KeySize |
Gets or sets the size, in bits, of the secret key used by the AesCng algorithm. |

LegalBlockSizes |
Gets the block sizes, in bits, that are supported by the symmetric algorithm. (Inherited from Aes) |

LegalKeySizes |
Gets the key sizes, in bits, that are supported by the symmetric algorithm. (Inherited from Aes) |

Mode |
Gets or sets the mode for operation of the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

Padding |
Gets or sets the padding mode used in the symmetric algorithm. (Inherited from SymmetricAlgorithm) |

## Methods

Clear() |
Releases all resources used by the SymmetricAlgorithm class. (Inherited from SymmetricAlgorithm) |

CreateDecryptor() |
Creates a symmetric AES decryptor object with the current key and initialization vector (IV). |

CreateDecryptor(Byte[], Byte[]) |
Creates a symmetric AES decryptor object with the specified key and initialization vector (IV). |

CreateEncryptor() |
Creates a symmetric AES encryptor object using the current key and initialization vector (IV). |

CreateEncryptor(Byte[], Byte[]) |
Creates a symmetric AES encryptor object with the specified key and initialization vector (IV). |

Dispose() |
Releases all resources used by the current instance of the SymmetricAlgorithm class. (Inherited from SymmetricAlgorithm) |

Dispose(Boolean) |
Releases the unmanaged resources used by the SymmetricAlgorithm and optionally releases the managed resources. (Inherited from SymmetricAlgorithm) |

Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |

GenerateIV() |
Generates a random initialization vector (IV) to use for the AES algorithm. |

GenerateKey() |
Generates a random key to use for the AES algorithm. |

GetHashCode() |
Serves as the default hash function. (Inherited from Object) |

GetType() |
Gets the Type of the current instance. (Inherited from Object) |

MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |

ToString() |
Returns a string that represents the current object. (Inherited from Object) |

ValidKeySize(Int32) |
Determines whether the specified key size is valid for the current algorithm. (Inherited from SymmetricAlgorithm) |

## Explicit Interface Implementations

IDisposable.Dispose() |
This API supports the product infrastructure and is not intended to be used directly from your code. Releases the unmanaged resources used by the SymmetricAlgorithm and optionally releases the managed resources. (Inherited from SymmetricAlgorithm) |