Table of Contents

Class CryptoAlgorithm

Namespace
Ecng.Security
Assembly
Ecng.Security.dll

Crypto algorithm.

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

Constructors

CryptoAlgorithm(AsymmetricCryptographer)

Initializes a new instance of the CryptoAlgorithm class.

public CryptoAlgorithm(AsymmetricCryptographer asymmetric)

Parameters

asymmetric AsymmetricCryptographer

AsymmetricCryptographer

CryptoAlgorithm(HashCryptographer)

Initializes a new instance of the CryptoAlgorithm class.

public CryptoAlgorithm(HashCryptographer hash)

Parameters

hash HashCryptographer

HashCryptographer

CryptoAlgorithm(SymmetricCryptographer)

Initializes a new instance of the CryptoAlgorithm class.

public CryptoAlgorithm(SymmetricCryptographer symmetric)

Parameters

symmetric SymmetricCryptographer

SymmetricCryptographer

Fields

DefaultAsymmetricAlgoName

The default asymmetric algorithm name.

public const string DefaultAsymmetricAlgoName = "RSA"

Field Value

string

DefaultHashAlgoName

The default hash algorithm name.

public const string DefaultHashAlgoName = "SHA"

Field Value

string

DefaultSymmetricAlgoName

The default symmetric algorithm name.

public const string DefaultSymmetricAlgoName = "AES"

Field Value

string

Methods

Create(AlgorithmTypes, params byte[][])

Creates a symmetric cryptographer.

public static CryptoAlgorithm Create(AlgorithmTypes type, params byte[][] keys)

Parameters

type AlgorithmTypes

AlgorithmTypes

keys byte[][]

The keys.

Returns

CryptoAlgorithm

CryptoAlgorithm

CreateAssymetricVerifier(byte[])

Creates a symmetric cryptographer.

public static CryptoAlgorithm CreateAssymetricVerifier(byte[] publicKey)

Parameters

publicKey byte[]

The public key.

Returns

CryptoAlgorithm

The symmetric cryptographer.

CreateSignature(byte[])

Computes the hash value of the plaintext.

public byte[] CreateSignature(byte[] data)

Parameters

data byte[]

The plaintext in which you wish to hash.

Returns

byte[]

The resulting hash.

Decrypt(byte[])

Decrypts the specified data.

public byte[] Decrypt(byte[] data)

Parameters

data byte[]

The encrypted data.

Returns

byte[]

The decrypted data.

DisposeManaged()

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

protected override void DisposeManaged()

Encrypt(byte[])

Encrypts the specified data.

public byte[] Encrypt(byte[] data)

Parameters

data byte[]

The decrypted data.

Returns

byte[]

The encrypted data.

VerifySignature(byte[], byte[])

Verifies the signature.

public bool VerifySignature(byte[] data, byte[] signature)

Parameters

data byte[]

The data.

signature byte[]

The signature.

Returns

bool

true if the signature is valid; otherwise, false.