EnvelopedCms.Encrypt Method

Definition

Encrypts the contents of the CMS/PKCS#7 message.

Overloads

Encrypt()

Encrypts the contents of the CMS/PKCS#7 message after selecting recipient certificates via a UI popup.

Encrypt(CmsRecipient)

Encrypts the contents of the CMS/PKCS#7 message for a single specified recipient.

Encrypt(CmsRecipientCollection)

Encrypts the contents of the CMS/PKCS#7 message for one or more recipients.

Encrypt()

Encrypts the contents of the CMS/PKCS#7 message after selecting recipient certificates via a UI popup.

C#
public void Encrypt ();

Exceptions

A cryptographic operation could not be completed.

Remarks

This method displays a user interface in which you choose the recipients for whom to encrypt the message. This requires that the current process is running in user interactive mode, meaning that the Environment.UserInteractive property is true. A process is normally in user interactive mode unless it is a service process or running inside a Web application.

The user interface will only present certificates that are within their validity period and that have Key Encipherment or Key Agreement included in their key usage.

The following permissions are required to display the user interface on .NET Framework:

Applies to

.NET Framework 4.8.1 والإصدارات الأخرى
منتج الإصدارات
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Encrypt(CmsRecipient)

Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs

Encrypts the contents of the CMS/PKCS#7 message for a single specified recipient.

C#
public void Encrypt (System.Security.Cryptography.Pkcs.CmsRecipient recipient);

Parameters

recipient
CmsRecipient

The recipient information describing the single recipient of this message.

Exceptions

The recipient parameter is null.

A cryptographic operation could not be completed.

See also

Applies to

.NET 9 (package-provided) والإصدارات الأخرى
منتج الإصدارات
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Encrypt(CmsRecipientCollection)

Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs
Source:
EnvelopedCms.cs

Encrypts the contents of the CMS/PKCS#7 message for one or more recipients.

C#
public void Encrypt (System.Security.Cryptography.Pkcs.CmsRecipientCollection recipients);

Parameters

recipients
CmsRecipientCollection

A collection describing the recipients for the message.

Exceptions

The recipients parameter is null.

A cryptographic operation could not be completed.

Applies to

.NET 9 (package-provided) والإصدارات الأخرى
منتج الإصدارات
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9