Multipart EncryptedEncrypt(Open Pgp Context, Encryption Algorithm, IEnumerablePgpPublicKey, Mime Entity, Cancellation Token) Method
Create a multipart/encrypted MIME part by encrypting the specified entity.
Definition
Namespace: MimeKit.Cryptography
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
A new MultipartEncrypted instance containing the encrypted version of the specified entity.
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public static MultipartEncrypted Encrypt(
OpenPgpContext ctx,
EncryptionAlgorithm algorithm,
IEnumerable<PgpPublicKey> recipients,
MimeEntity entity,
CancellationToken cancellationToken = default
)Parameters
- ctx OpenPgpContext
- The OpenPGP cryptography context to use for encrypting.
- algorithm EncryptionAlgorithm
- The encryption algorithm.
- recipients IEnumerablePgpPublicKey
- The recipients for the encrypted entity.
- entity MimeEntity
- The entity to sign and encrypt.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Return Value
MultipartEncryptedA new MultipartEncrypted instance containing the encrypted version of the specified entity.
Remarks
Encrypts the entity to the specified recipients, encapsulating the result in a
new multipart/encrypted part.
Exceptions
| ArgumentNullException |
ctx is . -or- recipients is . -or- entity is . |
| ArgumentException | One or more of the recipient keys cannot be used for encrypting. |
| NotSupportedException | The specified encryption algorithm is not supported. |
| ObjectDisposedException | entity has been disposed. |
| OperationCanceledException | The operation was canceled via the cancellation token. |