SignedCms.Decode 方法

定義

多載

Decode(Byte[])

將已編碼的 SignedCms 訊息進行解碼。

Decode(ReadOnlySpan<Byte>)

Decode(Byte[])

來源:
SignedCms.cs
來源:
SignedCms.cs
來源:
SignedCms.cs

將已編碼的 SignedCms 訊息進行解碼。

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

參數

encodedMessage
Byte[]

位元組值陣列,代表要解碼之已編碼的 CMS/PKCS#7 訊息。

例外狀況

encodedMessagenull

無法成功解碼 encodedMessage

範例

下列範例顯示方法在驗證訊息簽章 SignedCms 的過程中的位置 Decode 。 在此範例中,訊息內容不會中斷連結,因此訊息內容會包含在訊息中 SignedCms

// 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)

下列範例顯示方法在驗證訊息簽章 SignedCms 的過程中的位置 Decode 。 在此範例中,訊息內容會中斷連結,因此訊息內容必須獨立于訊息外驗證 SignedCms

// 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)

備註

這個方法會使用從成功解碼取得的資訊來重設物件的所有成員變數。

另請參閱

適用於

Decode(ReadOnlySpan<Byte>)

來源:
SignedCms.cs
來源:
SignedCms.cs
來源:
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))

參數

encodedMessage
ReadOnlySpan<Byte>

唯讀的位元組範圍值,代表要解碼的已編碼 CMS/PKCS #7 訊息。

例外狀況

無法成功解碼 encodedMessage

另請參閱

適用於