Table of Contents

Class SymmetricCryptographer

Namespace
Ecng.Security.Cryptographers
Assembly
Ecng.Security.dll

Represents basic cryptography services for a SymmetricAlgorithm.

public class SymmetricCryptographer : Disposable, IDisposable
Inheritance
SymmetricCryptographer
Implements
Inherited Members
Extension Methods

Remarks

Because the IV (Initialization Vector) has the same distribution as the resulting ciphertext, the IV is randomly generated and prepended to the ciphertext.

Constructors

SymmetricCryptographer(SymmetricAlgorithm, byte[])

Initalize a new instance of the SymmetricCryptographer class with an algorithm type and a key.

public SymmetricCryptographer(SymmetricAlgorithm algorithm, byte[] key)

Parameters

algorithm SymmetricAlgorithm

The qualified assembly name of a SymmetricAlgorithm.

key byte[]

The key for the algorithm.

Methods

Decrypt(byte[])

Decrypts bytes with the initialized algorithm and key.

public byte[] Decrypt(byte[] encryptedText)

Parameters

encryptedText byte[]

The text which you wish to decrypt.

Returns

byte[]

The resulting plaintext.

DisposeManaged()

Disposes the managed resources. Override this method to add custom clean up of managed resources.

protected override void DisposeManaged()

Encrypt(byte[])

Encrypts bytes with the initialized algorithm and key.

public byte[] Encrypt(byte[] plaintext)

Parameters

plaintext byte[]

The plaintext in which you wish to encrypt.

Returns

byte[]

The resulting ciphertext.

ZeroOutBytes(byte[])

Fills bytes zeros.

public static void ZeroOutBytes(byte[] bytes)

Parameters

bytes byte[]

The byte array to fill.