MD5CryptoServiceProvider 類別

定義

警告

Derived cryptographic types are obsolete. Use the Create method on the base type instead.

使用密碼編譯服務提供者 (CSP) 所提供之實作,計算輸入資料的 MD5 雜湊值。 此類別無法獲得繼承。

public ref class MD5CryptoServiceProvider sealed : System::Security::Cryptography::MD5
public sealed class MD5CryptoServiceProvider : System.Security.Cryptography.MD5
[System.Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class MD5CryptoServiceProvider : System.Security.Cryptography.MD5
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class MD5CryptoServiceProvider : System.Security.Cryptography.MD5
type MD5CryptoServiceProvider = class
    inherit MD5
[<System.Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type MD5CryptoServiceProvider = class
    inherit MD5
[<System.Runtime.InteropServices.ComVisible(true)>]
type MD5CryptoServiceProvider = class
    inherit MD5
Public NotInheritable Class MD5CryptoServiceProvider
Inherits MD5
繼承
MD5CryptoServiceProvider
屬性

備註

雜湊函式會將任意長度的二進位字串對應至固定長度的小型二進位字串。 密碼編譯雜湊函式具有無法計算的 屬性,可尋找雜湊為相同值的兩個相異輸入;也就是說,如果對應的資料也相符,則兩組資料的雜湊應該相符。 對資料的小型變更會導致雜湊中發生大型、無法預測的變更。

注意

有較新的雜湊函式,例如安全雜湊演算法 SHA-256 和 SHA-512。 請考慮使用 SHA256 類別或 SHA512 類別,而不是 類別 MD5CryptoServiceProviderMD5CryptoServiceProvider僅用於與繼承應用程式和資料的相容性。

類別的 MD5CryptoServiceProvider 雜湊大小為 128 位。

類別 ComputeHash 的方法會以 16 個位元組的 MD5CryptoServiceProvider 陣列傳回雜湊。 請注意,某些 MD5 實作會產生 32 個字元的十六進位格式雜湊。 若要與這類實作交互操作,請將方法的 ComputeHash 傳回值格式化為十六進位值。

建構函式

MD5CryptoServiceProvider()

初始化 MD5CryptoServiceProvider 類別的新執行個體。

欄位

HashSizeInBits

MD5 演算法所產生的雜湊大小,以位為單位。

(繼承來源 MD5)
HashSizeInBytes

MD5 演算法所產生的雜湊大小,以位元組為單位。

(繼承來源 MD5)
HashSizeValue

代表計算出來之雜湊碼的大小,以位元為單位。

(繼承來源 HashAlgorithm)
HashValue

表示計算出來的雜湊碼的值。

(繼承來源 HashAlgorithm)
State

表示雜湊計算的狀態。

(繼承來源 HashAlgorithm)

屬性

CanReuseTransform

取得值,表示目前的轉換是否可重複使用。

(繼承來源 HashAlgorithm)
CanTransformMultipleBlocks

在衍生類別中覆寫時,取得值以指出是否有多個區塊可被轉換。

(繼承來源 HashAlgorithm)
Hash

取得計算出來之雜湊碼的值。

(繼承來源 HashAlgorithm)
HashSize

取得計算出來之雜湊碼的大小,以位元為單位。

(繼承來源 HashAlgorithm)
InputBlockSize

在衍生類別中覆寫時,取得輸入區塊的大小。

(繼承來源 HashAlgorithm)
OutputBlockSize

在衍生類別中覆寫時,取得輸出區塊的大小。

(繼承來源 HashAlgorithm)

方法

Clear()

釋放 HashAlgorithm 類別所使用的所有資源。

(繼承來源 HashAlgorithm)
ComputeHash(Byte[])

計算指定位元組陣列的雜湊值。

(繼承來源 HashAlgorithm)
ComputeHash(Byte[], Int32, Int32)

計算所指定位元組陣列中指定區域的雜湊值。

(繼承來源 HashAlgorithm)
ComputeHash(Stream)

計算指定 Stream 物件的雜湊值。

(繼承來源 HashAlgorithm)
ComputeHashAsync(Stream, CancellationToken)

以非同步方式計算指定 Stream 物件的雜湊值。

(繼承來源 HashAlgorithm)
Dispose()

釋放 HashAlgorithm 類別目前的執行個體所使用的全部資源。

(繼承來源 HashAlgorithm)
Dispose(Boolean)

釋放 HashAlgorithm 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 HashAlgorithm)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Finalize()

釋放 MD5CryptoServiceProvider 正在使用的資源。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
HashCore(Byte[], Int32, Int32)

在衍生類別中覆寫時,將寫入物件的資料轉遞到用來計算雜湊的雜湊演算法。

(繼承來源 HashAlgorithm)
HashCore(ReadOnlySpan<Byte>)

將寫入物件的資料路由傳送至雜湊演算法,以用來計算雜湊。

(繼承來源 HashAlgorithm)
HashFinal()

於衍生類型中覆寫時,在密碼編譯雜湊演算法處理最後一筆資料後,完成雜湊計算。

(繼承來源 HashAlgorithm)
Initialize()

初始化 MD5CryptoServiceProvider 的執行個體。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TransformBlock(Byte[], Int32, Int32, Byte[], Int32)

計算輸入位元組陣列中指定區域的雜湊值,並將指定的輸入位元組陣列區域複製到指定的輸出位元組陣列區域。

(繼承來源 HashAlgorithm)
TransformFinalBlock(Byte[], Int32, Int32)

計算所指定位元組陣列中指定區域的雜湊值。

(繼承來源 HashAlgorithm)
TryComputeHash(ReadOnlySpan<Byte>, Span<Byte>, Int32)

嘗試計算指定位元組陣列的雜湊值。

(繼承來源 HashAlgorithm)
TryHashFinal(Span<Byte>, Int32)

在雜湊演算法處理最後一筆資料之後,嘗試完成雜湊計算。

(繼承來源 HashAlgorithm)

明確介面實作

IDisposable.Dispose()

釋放 HashAlgorithm 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 HashAlgorithm)

適用於

另請參閱