Multipart EncryptedSign And Encrypt Async(Open Pgp Context, Mailbox Address, Digest Algorithm, IEnumerableMailbox Address, Mime Entity, Cancellation Token) Method
Asynchronously create a multipart/encrypted MIME part by signing and 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 signed and encrypted version of the specified entity.
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public static Task<MultipartEncrypted> SignAndEncryptAsync(
OpenPgpContext ctx,
MailboxAddress signer,
DigestAlgorithm digestAlgo,
IEnumerable<MailboxAddress> recipients,
MimeEntity entity,
CancellationToken cancellationToken = default
)Parameters
- ctx OpenPgpContext
- The OpenPGP cryptography context to use for signing and encrypting.
- signer MailboxAddress
- The signer to use to sign the entity.
- digestAlgo DigestAlgorithm
- The digest algorithm to use for signing.
- recipients IEnumerableMailboxAddress
- The recipients for the encrypted entity.
- entity MimeEntity
- The entity to sign and encrypt.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Return Value
TaskMultipartEncryptedA new MultipartEncrypted instance containing the signed and encrypted version of the specified entity.
Remarks
Signs the entity using the supplied signer and digest algorithm and then encrypts to
the specified recipients, encapsulating the result in a new multipart/encrypted part.
Exceptions
| ArgumentNullException |
ctx is . -or- signer is . -or- recipients is . -or- entity is . |
| PrivateKeyNotFoundException | The private key for signer could not be found. |
| PublicKeyNotFoundException | A public key for one or more of the recipients could not be found. |
| ObjectDisposedException | entity has been disposed. |
| OperationCanceledException |
The user chose to cancel the password prompt. -or- The operation was canceled via the cancellation token. |
| UnauthorizedAccessException | 3 bad attempts were made to unlock the secret key. |