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
algorithmAsymmetricAlgorithmThe qualified assembly name of a SymmetricAlgorithm.
publicKeybyte[]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
algorithmAsymmetricAlgorithmThe qualified assembly name of a SymmetricAlgorithm.
publicKeybyte[]The public key for the algorithm.
privateKeybyte[]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
encryptorAsymmetricAlgorithmThe encryptor.
decryptorAsymmetricAlgorithmThe 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
algorithmAsymmetricAlgorithmprivateKeybyte[]The private key for the algorithm.
Returns
CreateFromPublicKey(AsymmetricAlgorithm, byte[])
Creates a new instance of the AsymmetricCryptographer class with a public key.
public static AsymmetricCryptographer CreateFromPublicKey(AsymmetricAlgorithm algorithm, byte[] publicKey)
Parameters
algorithmAsymmetricAlgorithmpublicKeybyte[]The public key for the algorithm.
Returns
CreateSignature(byte[])
Computes the hash value of the plaintext.
public byte[] CreateSignature(byte[] data)
Parameters
databyte[]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
encryptedTextbyte[]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
plainTextbyte[]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
Returns
- bool
trueif the signature is valid; otherwise,false.