SymmetricCryptographer

Represents basic cryptography services for a SymmetricAlgorithm.

Namespace:
Inetdev.Security.Cryptography
Type:
Class
Public:
Yes
Protected:
No
Sealed:
No
Abstract:
No
Inherits from:
System.Object
Implements:
Inetdev.Security.Cryptography.ISymmetricProvider, System.IDisposable

Constructors

SymmetricCryptographer

Initializes a new instance of SymmetricCryptographer.

Signature:
public Void SymmetricCryptographer(algorithmType, symmetricKey, previousSymmetricKey)
Remarks

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.

Parameters
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).
Exceptions
Type Summary
ArgumentException Thrown when the symmetric key length is invalid.
ArgumentNullException

Thrown when algorithmType is null.

-or- symmetricKey is null.

Methods

Decrypt

Decrypts a cypher text using a specified symmetric cryptography provider.

Signature:
public Byte[] Decrypt(ciphertext)
Returns

The resulting plain text.

Parameters
Name Type Summary
ciphertext Byte[] The cipher text to decrypt.
Exceptions
Type Summary
ArgumentNullException Thrown the ciphertext is null or empty.
CryptographyException Thrown when an error occurs while transforming the data.

Decrypt

Decrypts a cypher stream using the specified symmetric cryptograpy provider.

Signature:
public Void Decrypt(source, destination)
Parameters
Name Type Summary
source Stream The source stream to decript.
destination Stream The destination stream where the plain text result should be written.
Exceptions
Type Summary
ArgumentNullException

Thrown the source is null.

-or- destination is null.

CryptographyException Thrown when an error occurs while transforming the data.

Dispose

Executes application specific clean up code.

Signature:
public Void Dispose()

Encrypt

Encrypts a secret using a specified symmetric cryptography provider.

Signature:
public Byte[] Encrypt(plaintext)
Returns

The resulting cipher text.

Parameters
Name Type Summary
plaintext Byte[] The input to encrypt.
Exceptions
Type Summary
ArgumentNullException Thrown the plaintext is null or it is empty.
CryptographyException Thrown when an error occurs while transforming the data.

Encrypt

Encrypts a secret into the source stream using the specified cryptography provider.

Signature:
public Void Encrypt(source, destination)
Parameters
Name Type Summary
source Stream The source stream to encrypt.
destination Stream The destination stream where the cipher text should be written.
Exceptions
Type Summary
ArgumentNullException

Thrown the source is null.

-or- destination is null.

CryptographyException Thrown when an error occurs while transforming the data.