Click or drag to resize
MimeKit

MultipartEncryptedSignAndEncrypt(OpenPgpContext, PgpSecretKey, DigestAlgorithm, IEnumerablePgpPublicKey, MimeEntity, CancellationToken) Method

Create a multipart/encrypted MIME part by signing and encrypting the specified entity.

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public static MultipartEncrypted SignAndEncrypt(
	OpenPgpContext ctx,
	PgpSecretKey signer,
	DigestAlgorithm digestAlgo,
	IEnumerable<PgpPublicKey> recipients,
	MimeEntity entity,
	CancellationToken cancellationToken = default
)

Parameters

ctx  OpenPgpContext
The OpenPGP cryptography context to use for singing and encrypting.
signer  PgpSecretKey
The signer to use to sign the entity.
digestAlgo  DigestAlgorithm
The digest algorithm to use for signing.
recipients  IEnumerablePgpPublicKey
The recipients for the encrypted entity.
entity  MimeEntity
The entity to sign and encrypt.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

MultipartEncrypted
A new MultipartEncrypted instance containing the signed and encrypted version of the specified entity.
Exceptions
ExceptionCondition
ArgumentNullException

ctx is null.

-or-

signer is null.

-or-

recipients is null.

-or-

entity is null.

ArgumentException

signer cannot be used for signing.

-or-

One or more of the recipient keys cannot be used for encrypting.

-or-

No recipients were specified.

ArgumentOutOfRangeException The digestAlgo was out of range.
NotSupportedException The digestAlgo is not supported.
ObjectDisposedExceptionentity 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.
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.
See Also