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

EncryptedData.Encrypt method (Infocard.h)

· 52CE 我爱测

Derives a session key from the secret and encrypts the Content property value using that key. It returns the encrypted content as an encoded string.

[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 Platform Invocation Services (PInvoke) to call the Win32 API functions CryptEncryptMessage and CryptDecryptMessage to encrypt and decrypt messages. For information about PInvoke, see Platform Invoke Tutorial. The .NET and CryptoAPI via P/Invoke: Part 1 and .NET and CryptoAPI via P/Invoke: Part 2 subsections of Extending .NET Cryptography with CAPICOM and P/Invoke may also be helpful.]

The Encrypt method derives a session key from the secret and encrypts the Content property value using that key. It returns the encrypted content as an encoded string.

Syntax

EncryptedData.Encrypt( _
  [ ByVal EncodingType ] _
)

Parameters

EncodingType [in, optional]

A value of the CAPICOM_ENCODING_TYPE enumeration that indicates the encoding type used to encode the encrypted data. The default 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

A string that contains the encrypted, encoded data.

Remarks

Before calling the Encrypt method, set the Content property and call the SetSecret method.

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
Header Infocard.h
DLL Capicom.dll

See also

Cryptography Objects

EncryptedData

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)

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

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