共用方式為


HttpContentHeaderCollection.ContentMD5 屬性

定義

取得或設定 HTTP 內容上 HTTP Content-MD5 標頭的值。

public:
 property IBuffer ^ ContentMD5 { IBuffer ^ get(); void set(IBuffer ^ value); };
IBuffer ContentMD5();

void ContentMD5(IBuffer value);
public IBuffer ContentMD5 { get; set; }
var iBuffer = httpContentHeaderCollection.contentMD5;
httpContentHeaderCollection.contentMD5 = iBuffer;
Public Property ContentMD5 As IBuffer

屬性值

HTTP 內容上的 HTTP Content-MD5 標頭值。 Null值表示標頭不存在。

備註

下列範例程式碼示範使用HttpContentHeaderCollection物件上的 ContentMD5 屬性,在 HTTP 內容上取得或設定Content-MD5標頭值的方法。

// Content-MD5 header
// IBuffer
void DemoContentMD5(IHttpContent content) {
    var h = content.Headers;

    var str = "This is my content string";
    var alg = Windows.Security.Cryptography.Core.HashAlgorithmProvider.OpenAlgorithm("MD5");
    var buff = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(str, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);
    var hashed = alg.HashData(buff);
    var res = Windows.Security.Cryptography.CryptographicBuffer.EncodeToHexString(hashed);
    h.ContentMD5 = hashed;

    var header = h.ContentMD5;
    uiLog.Text += "\nCONTENT MD5 HEADER\n";

    uiLog.Text += string.Format("ContentMD5: ToString: {0}\n\n", header.ToString());
    uiLog.Text += string.Format("ContentMD5: base64: {0} hex: {1}\n\n", Convert.ToBase64String(h.ContentMD5.ToArray()), res);
}

適用於