Class AesProtector
Provides data protection using AES Cipher.
Namespace: Neon.Web
Assembly: Neon.Web.dll
Syntax
public class AesProtector
Constructors
AesProtector(AesCipher)
Constructor.
Declaration
public AesProtector(AesCipher aesCipher)
Parameters
Type | Name | Description |
---|---|---|
AesCipher | aesCipher |
Methods
CreateProtector(string)
Creates an IDataProtector given a purpose.
Declaration
public IDataProtector CreateProtector(string purpose)
Parameters
Type | Name | Description |
---|---|---|
string | purpose | The purpose to be assigned to the newly-created IDataProtector. |
Returns
Type | Description |
---|---|
IDataProtector | An IDataProtector tied to the provided purpose. |
Remarks
The purpose
parameter must be unique for the intended use case; two
different IDataProtector instances created with two different purpose
values will not be able to decipher each other's payloads. The purpose
parameter
value is not intended to be kept secret.
Protect(byte[])
Cryptographically protects a piece of plaintext data.
Declaration
public byte[] Protect(byte[] plaintext)
Parameters
Type | Name | Description |
---|---|---|
byte[] | plaintext | The plaintext data to protect. |
Returns
Type | Description |
---|---|
byte[] | The protected form of the plaintext data. |
Unprotect(byte[])
Cryptographically unprotects a piece of protected data.
Declaration
public byte[] Unprotect(byte[] protectedData)
Parameters
Type | Name | Description |
---|---|---|
byte[] | protectedData | The protected data to unprotect. |
Returns
Type | Description |
---|---|
byte[] | The plaintext form of the protected data. |
Exceptions
Type | Condition |
---|---|
CryptographicException | Thrown if the protected data is invalid or malformed. |