AsymmetricCryptographer

Ecng.Security.Cryptographers

Asymmetric cryptographer.

Hereda de: Disposable

Constructores

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

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

algorithm
The AsymmetricAlgorithm to use.
publicKey
The public key for the algorithm.
privateKey
The private key for the algorithm.
AsymmetricCryptographer
public AsymmetricCryptographer(AsymmetricAlgorithm algorithm, byte[] publicKey)
asymmetricCryptographer = AsymmetricCryptographer(algorithm, publicKey)

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

algorithm
The AsymmetricAlgorithm to use.
publicKey
The public key for the algorithm.
AsymmetricCryptographer
protected AsymmetricCryptographer(AsymmetricAlgorithm encryptor, AsymmetricAlgorithm decryptor)
asymmetricCryptographer = AsymmetricCryptographer(encryptor, decryptor)

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

encryptor
The encryptor.
decryptor
The decryptor.

Métodos

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

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

algorithm
AsymmetricAlgorithm
privateKey
The private key for the algorithm.

Devuelve: AsymmetricCryptographer

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

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

algorithm
AsymmetricAlgorithm
publicKey
The public key for the algorithm.

Devuelve: AsymmetricCryptographer

CreateSignature
public byte[] CreateSignature(byte[] data, Func<HashAlgorithm> createHash)
result = asymmetricCryptographer.CreateSignature(data, createHash)

Computes the hash value of the plaintext.

data
The plaintext in which you wish to hash.
createHash
A function that creates a HashAlgorithm instance to use for hashing.

Devuelve: The resulting hash.

Decrypt
public byte[] Decrypt(byte[] encryptedText)
result = asymmetricCryptographer.Decrypt(encryptedText)

Decrypts bytes with the initialized algorithm and key.

encryptedText
The text which you wish to decrypt.

Devuelve: The resulting plaintext.

DisposeManaged
protected override void DisposeManaged()
asymmetricCryptographer.DisposeManaged()

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

Encrypt
public byte[] Encrypt(byte[] plainText)
result = asymmetricCryptographer.Encrypt(plainText)

Encrypts bytes with the initialized algorithm and key.

plainText
The plaintext in which you wish to encrypt.

Devuelve: The resulting cipher text.

VerifySignature
public bool VerifySignature(byte[] data, byte[] signature)
result = asymmetricCryptographer.VerifySignature(data, signature)

Verifies the signature.

data
The data.
signature
The signature.

Devuelve: true if the signature is valid; otherwise, false.