Represents basic cryptography services for a SymmetricAlgorithm.
Initializes a new instance of SymmetricCryptographer.
public Void SymmetricCryptographer(algorithmType, symmetricKey, previousSymmetricKey)
If previous symmetric key is provided, it will ve used when decrypting if the decryption with the symmetricKey fails.
The symmetricKey and previousSymmetricKey parameters should be conformed by concatenating the initializacion vector (IV) and the symmetric key (Key) for the specified symmetric algorithm.
The length of the symmetricKey and previousSymmetricKey parameters should be the sum of the length of both fields as it will be validate against the BlockSize and KeySize field of the symmetric algorithm.
Name | Type | Summary |
---|---|---|
algorithmType | Type | The Type of a SymmetricAlgorithm. |
symmetricKey | Byte[] | The secret key for this symmetric cryptographer. |
previousSymmetricKey | Byte[] | Previous secret key for the symmetric algorithm (optional). |
Type | Summary |
---|---|
ArgumentException | Thrown when the symmetric key length is invalid. |
ArgumentNullException | Thrown when algorithmType is null. -or- symmetricKey is null. |
Decrypts a cypher text using a specified symmetric cryptography provider.
public Byte[] Decrypt(ciphertext)
The resulting plain text.
Name | Type | Summary |
---|---|---|
ciphertext | Byte[] | The cipher text to decrypt. |
Type | Summary |
---|---|
ArgumentNullException | Thrown the ciphertext is null or empty. |
CryptographyException | Thrown when an error occurs while transforming the data. |
Decrypts a cypher stream using the specified symmetric cryptograpy provider.
public Void Decrypt(source, destination)
Name | Type | Summary |
---|---|---|
source | Stream | The source stream to decript. |
destination | Stream | The destination stream where the plain text result should be written. |
Type | Summary |
---|---|
ArgumentNullException | Thrown the source is null. -or- destination is null. |
CryptographyException | Thrown when an error occurs while transforming the data. |
Executes application specific clean up code.
public Void Dispose()
Encrypts a secret using a specified symmetric cryptography provider.
public Byte[] Encrypt(plaintext)
The resulting cipher text.
Name | Type | Summary |
---|---|---|
plaintext | Byte[] | The input to encrypt. |
Type | Summary |
---|---|
ArgumentNullException | Thrown the plaintext is null or it is empty. |
CryptographyException | Thrown when an error occurs while transforming the data. |
Encrypts a secret into the source stream using the specified cryptography provider.
public Void Encrypt(source, destination)
Name | Type | Summary |
---|---|---|
source | Stream | The source stream to encrypt. |
destination | Stream | The destination stream where the cipher text should be written. |
Type | Summary |
---|---|
ArgumentNullException | Thrown the source is null. -or- destination is null. |
CryptographyException | Thrown when an error occurs while transforming the data. |