AsymmetricCryptographer
Asymmetric cryptographer.
Erbt von: Disposable
Konstruktoren
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.
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.
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.
Methoden
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.
Rückgabe: AsymmetricCryptographer
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.
Rückgabe: AsymmetricCryptographer
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.
Rückgabe: The resulting hash.
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.
Rückgabe: The resulting plaintext.
protected override void DisposeManaged()
asymmetricCryptographer.DisposeManaged()
Disposes the managed resources. Override this method to add custom clean up of managed resources.
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.
Rückgabe: The resulting cipher text.
public bool VerifySignature(byte[] data, byte[] signature)
result = asymmetricCryptographer.VerifySignature(data, signature)
Verifies the signature.
- data
- The data.
- signature
- The signature.
Rückgabe: true if the signature is valid; otherwise, false.