Click or drag to resize
MimeKit

MultipartEncryptedEncrypt(IEnumerablePgpPublicKey, MimeEntity, CancellationToken) Method

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

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public static MultipartEncrypted Encrypt(
	IEnumerable<PgpPublicKey> recipients,
	MimeEntity entity,
	CancellationToken cancellationToken = default
)

Parameters

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 encrypted version of the specified entity.
Exceptions
ExceptionCondition
ArgumentNullException

recipients is null.

-or-

entity is null.

ArgumentException One or more of the recipient keys cannot be used for encrypting.
NotSupportedException A default OpenPgpContext has not been registered.
ObjectDisposedExceptionentity has been disposed.
OperationCanceledException The operation was canceled via the cancellation token.
Remarks
Encrypts the entity to the specified recipients, encapsulating the result in a new multipart/encrypted part.
See Also