Encrypt Method
Collapse the table of content
Expand the table of content

EnvelopedData.Encrypt method

[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.

ValueMeaning
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

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

 

 

Show:
© 2016 Microsoft