大网数据广告活动
账户与安全

EnvelopedData.Encrypt method

· 52CE 我爱测

Generates a session key and encrypts and envelopes data.

[CAPICOM is a 32-bit only component that is available for use in the following operating systems: Windows Server 2008, Windows Vista, and Windows XP. Instead, use the EnvelopedCms Class in the System.Security.Cryptography.Pkcs namespace.]

The Encrypt method generates a session key, uses that key to encrypt the contents, envelops the encrypted content for each recipient by encrypting the session key with each recipient's public key, and then returns the BLOB that contains the encrypted contents and the encrypted session keys as an encoded string.

Syntax

EnvelopedData.Encrypt( _
  [ ByVal EncodingType ] _
)

Parameters

EncodingType [in, optional]

A value of the CAPICOM_ENCODING_TYPE enumeration that indicates the encoding type used to encode the enveloped data. The default encoding value is CAPICOM_ENCODE_BASE64. This parameter can be one of the following values.

Value Meaning
CAPICOM_ENCODE_ANY This encoding type is used only when the input data has an unknown encoding type. If this value is used to specify the output's encoding type, CAPICOM_ENCODE_BASE64 will be used instead. Introduced in CAPICOM 2.0.
CAPICOM_ENCODE_BASE64 Data is saved as a base64-encoded string.
CAPICOM_ENCODE_BINARY Data is saved as a pure binary sequence.

Return value

This method returns a BLOB that contains the enveloped data in an encoded string.

Remarks

The returned BLOB contains the encrypted content and an encrypted session key for each intended recipient. These session keys are encrypted using the public key of each recipient. The encrypted session keys can be decrypted only with a recipient's private key.

If the Recipients property does not contain any information, this method searches the current user's AddressBook certificate store for potential recipients. If more than one potential recipient is found, the user is prompted to select a recipient from a selection dialog box.

Requirements

Requirement Value
End of client support Windows Vista
End of server support Windows Server 2008
Redistributable CAPICOM 2.0 or later on Windows Server 2003 and Windows XP
DLL Capicom.dll

See also

Cryptography Objects

EnvelopedData

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。