Table of Contents

Class AsymmetricCryptographer

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

Asymmetric cryptographer.

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

Constructors

AsymmetricCryptographer(AsymmetricAlgorithm, byte[])

Initialize a new instance of the AsymmetricCryptographer class with an algorithm type and a key.

public AsymmetricCryptographer(AsymmetricAlgorithm algorithm, byte[] publicKey)

Parameters

algorithm AsymmetricAlgorithm

The qualified assembly name of a SymmetricAlgorithm.

publicKey byte[]

The public key for the algorithm.

AsymmetricCryptographer(AsymmetricAlgorithm, byte[], byte[])

Initialize a new instance of the AsymmetricCryptographer class with an algorithm type and a key.

public AsymmetricCryptographer(AsymmetricAlgorithm algorithm, byte[] publicKey, byte[] privateKey)

Parameters

algorithm AsymmetricAlgorithm

The qualified assembly name of a SymmetricAlgorithm.

publicKey byte[]

The public key for the algorithm.

privateKey byte[]

The private key for the algorithm.

AsymmetricCryptographer(AsymmetricAlgorithm, AsymmetricAlgorithm)

Initialize a new instance of the AsymmetricCryptographer class with an algorithm type and a key.

protected AsymmetricCryptographer(AsymmetricAlgorithm encryptor, AsymmetricAlgorithm decryptor)

Parameters

encryptor AsymmetricAlgorithm

The encryptor.

decryptor AsymmetricAlgorithm

The decryptor.

Methods

CreateFromPrivateKey(AsymmetricAlgorithm, byte[])

Creates a new instance of the AsymmetricCryptographer class with a private key.

public static AsymmetricCryptographer CreateFromPrivateKey(AsymmetricAlgorithm algorithm, byte[] privateKey)

Parameters

algorithm AsymmetricAlgorithm

AsymmetricAlgorithm

privateKey byte[]

The private key for the algorithm.

Returns

AsymmetricCryptographer

AsymmetricCryptographer

CreateFromPublicKey(AsymmetricAlgorithm, byte[])

Creates a new instance of the AsymmetricCryptographer class with a public key.

public static AsymmetricCryptographer CreateFromPublicKey(AsymmetricAlgorithm algorithm, byte[] publicKey)

Parameters

algorithm AsymmetricAlgorithm

AsymmetricAlgorithm

publicKey byte[]

The public key for the algorithm.

Returns

AsymmetricCryptographer

AsymmetricCryptographer

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 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 cipher text.

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.