SignedCms.Decode Method

Definition

Overloads

Decode(Byte[])

Decodes an encoded SignedCms message.

Decode(ReadOnlySpan<Byte>)

Decode(Byte[])

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs

Decodes an encoded SignedCms message.

public:
 void Decode(cli::array <System::Byte> ^ encodedMessage);
public void Decode (byte[] encodedMessage);
member this.Decode : byte[] -> unit
Public Sub Decode (encodedMessage As Byte())

Parameters

encodedMessage
Byte[]

An array of byte values that represents the encoded CMS/PKCS#7 message to be decoded.

Exceptions

encodedMessage is null.

encodedMessage could not be decoded successfully.

Examples

The following example shows the placement of the Decode method in the process of verifying the signatures on a SignedCms message. In this example, the message content is not detached, so the message content is included in the SignedCms message.

// Create a new, nondetached SignedCms message.
SignedCms signedCms = new SignedCms();

// encodedMessage is the encoded message received from
// the sender.
signedCms.Decode(encodedMessage);

// Verify the signature without validating the
// certificate.
signedCms.CheckSignature(true);
' Create a new, nondetached SignedCms message.
Dim signedCms As New SignedCms()

' encodedMessage is the encoded message received from 
' the sender.
signedCms.Decode(encodedMessage)

' Verify the signature without validating the 
' certificate.
signedCms.CheckSignature(True)

The following example shows the placement of the Decode method in the process of verifying the signatures on a SignedCms message. In this example, the message content is detached, so the message content must be verified independently of the SignedCms message.

// Create a ContentInfo object from the inner content obtained
// independently from encodedMessage.
ContentInfo contentInfo = new ContentInfo(innerContent);

// Create a new, detached SignedCms message.
SignedCms signedCms = new SignedCms(contentInfo, true);

// encodedMessage is the encoded message received from
// the sender.
signedCms.Decode(encodedMessage);

// Verify the signature without validating the
// certificate.
signedCms.CheckSignature(true);
' Create a ContentInfo object from the inner content obtained 
' independently from encodedMessage.
Dim contentInfo As New ContentInfo(innerContent)

' Create a new, detached SignedCms message.
Dim signedCms As New SignedCms(contentInfo, True)

' encodedMessage is the encoded message received from 
' the sender.
signedCms.Decode(encodedMessage)

' Verify the signature without validating the 
' certificate.
signedCms.CheckSignature(True)

Remarks

This method resets all member variables of the object by using the information obtained from successful decoding.

See also

Applies to

Decode(ReadOnlySpan<Byte>)

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
public:
 void Decode(ReadOnlySpan<System::Byte> encodedMessage);
public void Decode (ReadOnlySpan<byte> encodedMessage);
member this.Decode : ReadOnlySpan<byte> -> unit
Public Sub Decode (encodedMessage As ReadOnlySpan(Of Byte))

Parameters

encodedMessage
ReadOnlySpan<Byte>

A read-only span of byte values that represents the encoded CMS/PKCS#7 message to be decoded.

Exceptions

encodedMessage could not be decoded successfully.

See also

Applies to