Collapse AllExpand All      Code: All Code: Multiple Code: Visual Basic Code: C# Code: Visual C++ Code: F# Code: JScript 
SymmetricAlgorithm Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents the abstract base class from which all implementations of symmetric algorithms must inherit.

Namespace:   System.Security.Cryptography
Assembly:  System.Security (in System.Security.dll)
Public MustInherit Class SymmetricAlgorithm _
	Inherits SessionContainer
public abstract class SymmetricAlgorithm : SessionContainer
public ref class SymmetricAlgorithm abstract : public SessionContainer
[<AbstractClass>]
type SymmetricAlgorithm =  
    class
        inherit SessionContainer
    end
public abstract class SymmetricAlgorithm extends SessionContainer

The SymmetricAlgorithm type exposes the following members.

  NameDescription
Protected method SymmetricAlgorithmInitializes a new instance of the SymmetricAlgorithm class.
Top
  NameDescription
Public property BlockSizeGets or sets the block size, in bits, of the cryptographic operation.
Public property FeedbackSizeGets or sets the feedback size, in bits, of the cryptographic operation.
Public property IsDisposed (Inherited from SessionContainer.)
Public property IVGets or sets the initialization vector ( IV) for the symmetric algorithm.
Public property KeyGets or sets the secret key for the symmetric algorithm.
Public property KeySizeGets or sets the size, in bits, of the secret key used by the symmetric algorithm.
Public property LegalBlockSizesGets the block sizes, in bits, that are supported by the symmetric algorithm.
Public property LegalKeySizesGets the key sizes, in bits, that are supported by the symmetric algorithm.
Protected property MechanismTypeGets the symmetric algorithm type.
Public property ModeGets or sets the mode for operation of the symmetric algorithm.
Public property PaddingGets or sets the padding mode used in the symmetric algorithm.
Public property Session (Inherited from SessionContainer.)
Top
  NameDescription
Public method ClearReleases all resources used by the SymmetricAlgorithm class.
Public method CreateDecryptor()()()()Creates a symmetric decryptor object with the current Key property and initialization vector ( IV).
Public method CreateDecryptor(CryptoKey, array<Byte>[]()[][])When overridden in a derived class, creates a symmetric decryptor object with the specified Key property and initialization vector ( IV).
Public method CreateEncryptor()()()()Creates a symmetric encryptor object with the current Key property and initialization vector ( IV).
Public method CreateEncryptor(CryptoKey, array<Byte>[]()[][])When overridden in a derived class, creates a symmetric encryptor object with the specified Key property and initialization vector ( IV).
Public method Dispose()()()() (Inherited from SessionContainer.)
Protected method Dispose(Boolean)Releases the unmanaged resources used by the SymmetricAlgorithm and optionally releases the managed resources. (Overrides SessionContainer..::..Dispose(Boolean).)
Public method Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize (Inherited from SessionContainer.)
Public method GenerateIVWhen overridden in a derived class, generates a random initialization vector ( IV) to use for the algorithm.
Public method GenerateKeyWhen overridden in a derived class, generates a random key ( Key) to use for the algorithm.
Public method GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Public method ValidKeySizeDetermines whether the specified key size is valid for the current algorithm.
Top
  NameDescription
Protected field BlockSizeValueRepresents the block size, in bits, of the cryptographic operation.
Protected field FeedbackSizeValueRepresents the feedback size, in bits, of the cryptographic operation.
Protected field IVValueRepresents the initialization vector ( IV) for the symmetric algorithm.
Protected field KeySizeValueRepresents the size, in bits, of the secret key used by the symmetric algorithm.
Protected field KeyValueRepresents the secret key for the symmetric algorithm.
Protected field LegalBlockSizesValueSpecifies the block sizes, in bits, that are supported by the symmetric algorithm.
Protected field LegalKeySizesValueSpecifies the key sizes, in bits, that are supported by the symmetric algorithm.
Protected field m_isDisposed (Inherited from SessionContainer.)
Protected field m_isSessionClosing (Inherited from SessionContainer.)
Protected field m_ownsSession (Inherited from SessionContainer.)
Protected field m_session (Inherited from SessionContainer.)
Protected field ModeValueRepresents the cipher mode used in the symmetric algorithm.
Protected field OwnsKeyRepresents the value that indicates whether the algorithm object owns the key.
Protected field PaddingValueRepresents the padding mode used in the symmetric algorithm.
Top

The classes that derive from the SymmetricAlgorithm class use a chaining mode called cipher block chaining (CBC), which requires a key ( Key) and an initialization vector ( IV) to perform cryptographic transformations on data. To decrypt data that was encrypted using one of the SymmetricAlgorithm classes, you must set the Key property and the IV property to the same values that were used for encryption. For a symmetric algorithm to be useful, the secret key must be known only to the sender and the receiver.

All cryptographic classes in the .NET Framework that hold sensitive data implement a Clear method. When called, the Clear method overwrites all sensitive data within the object with zeros and then releases the object so that it can be safely garbage collected. When the object has been zeroed and released, you should then call the Dispose method with the disposing parameter set to True to dispose of all managed and unmanaged resources associated with the object.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.