MD5CryptoServiceProvider 類別

定義

使用密碼編譯服務提供者 (CSP) 所提供之實作,計算輸入資料的 MD5 雜湊值。Computes the MD5 hash value for the input data using the implementation provided by the cryptographic service provider (CSP). 此類別無法獲得繼承。This class cannot be inherited.

public ref class MD5CryptoServiceProvider sealed : System::Security::Cryptography::MD5
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.Runtime.InteropServices.ComVisible(true)>]
type MD5CryptoServiceProvider = class
    inherit MD5
Public NotInheritable Class MD5CryptoServiceProvider
Inherits MD5
繼承
MD5CryptoServiceProvider
屬性

備註

雜湊函數會將任意長度的二進位字串對應至固定長度的小型二進位字串。Hash functions map binary strings of an arbitrary length to small binary strings of a fixed length. 密碼編譯雜湊函式的屬性是,如果找不到可雜湊為相同值的兩個不同輸入,則不能進行運算。也就是說,如果對應的資料也符合,則兩組資料的雜湊應該相符。A cryptographic hash function has the property that it is computationally infeasible to find two distinct inputs that hash to the same value; that is, hashes of two sets of data should match if the corresponding data also matches. 對資料進行較小的變更會導致雜湊中的大型、無法預測的變更。Small changes to the data result in large, unpredictable changes in the hash.

注意

您可以使用較新的雜湊函式,例如安全雜湊演算法 SHA-256 和 SHA-512。Newer hash functions such as the Secure Hash Algorithms SHA-256 and SHA-512 are available. 請考慮使用 SHA256 類別或類別, SHA512 而不是 MD5CryptoServiceProvider 類別。Consider using the SHA256 class or the SHA512 class instead of the MD5CryptoServiceProvider class. MD5CryptoServiceProvider僅用於與繼承應用程式和資料的相容性。Use MD5CryptoServiceProvider only for compatibility with legacy applications and data.

類別的雜湊大小 MD5CryptoServiceProvider 為128位。The hash size for the MD5CryptoServiceProvider class is 128 bits.

類別的方法會將 ComputeHash MD5CryptoServiceProvider 雜湊以16位元組的陣列傳回。The ComputeHash methods of the MD5CryptoServiceProvider class return the hash as an array of 16 bytes. 請注意,某些 MD5 的執行會產生32字元的十六進位格式雜湊。Note that some MD5 implementations produce a 32-character, hexadecimal-formatted hash. 若要與這類的執行相交互操作,請將方法的傳回值格式化 ComputeHash 為十六進位值。To interoperate with such implementations, format the return value of the ComputeHash methods as a hexadecimal value.

建構函式

MD5CryptoServiceProvider()

初始化 MD5CryptoServiceProvider 類別的新執行個體。Initializes a new instance of the MD5CryptoServiceProvider class.

欄位

HashSizeValue

代表計算出來之雜湊碼的大小,以位元為單位。Represents the size, in bits, of the computed hash code.

(繼承來源 HashAlgorithm)
HashValue

表示計算出來的雜湊碼的值。Represents the value of the computed hash code.

(繼承來源 HashAlgorithm)
State

表示雜湊計算的狀態。Represents the state of the hash computation.

(繼承來源 HashAlgorithm)

屬性

CanReuseTransform

取得值,表示目前的轉換是否可重複使用。Gets a value indicating whether the current transform can be reused.

(繼承來源 HashAlgorithm)
CanTransformMultipleBlocks

在衍生類別中覆寫時,取得值以指出是否有多個區塊可被轉換。When overridden in a derived class, gets a value indicating whether multiple blocks can be transformed.

(繼承來源 HashAlgorithm)
Hash

取得計算出來之雜湊碼的值。Gets the value of the computed hash code.

(繼承來源 HashAlgorithm)
HashSize

取得計算出來之雜湊碼的大小,以位元為單位。Gets the size, in bits, of the computed hash code.

(繼承來源 HashAlgorithm)
InputBlockSize

在衍生類別中覆寫時,取得輸入區塊的大小。When overridden in a derived class, gets the input block size.

(繼承來源 HashAlgorithm)
OutputBlockSize

在衍生類別中覆寫時,取得輸出區塊的大小。When overridden in a derived class, gets the output block size.

(繼承來源 HashAlgorithm)

方法

Clear()

釋放 HashAlgorithm 類別所使用的所有資源。Releases all resources used by the HashAlgorithm class.

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

計算指定位元組陣列的雜湊值。Computes the hash value for the specified byte array.

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

計算所指定位元組陣列中指定區域的雜湊值。Computes the hash value for the specified region of the specified byte array.

(繼承來源 HashAlgorithm)
ComputeHash(Stream)

計算指定 Stream 物件的雜湊值。Computes the hash value for the specified Stream object.

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

以非同步方式計算指定 Stream 物件的雜湊值。Asynchronously computes the hash value for the specified Stream object.

(繼承來源 HashAlgorithm)
Dispose()

釋放 HashAlgorithm 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the HashAlgorithm class.

(繼承來源 HashAlgorithm)
Dispose(Boolean)

釋放 HashAlgorithm 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the HashAlgorithm and optionally releases the managed resources.

(繼承來源 HashAlgorithm)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Finalize()

釋放 MD5CryptoServiceProvider 正在使用的資源。Releases the resources that are being used by the MD5CryptoServiceProvider.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

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

在衍生類別中覆寫時,將寫入物件的資料轉遞到用來計算雜湊的雜湊演算法。When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash.

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

將寫入物件的資料路由傳送至雜湊演算法,以用來計算雜湊。Routes data written to the object into the hash algorithm for computing the hash.

(繼承來源 HashAlgorithm)
HashFinal()

於衍生類型中覆寫時,在密碼編譯雜湊演算法處理最後一筆資料後,完成雜湊計算。When overridden in a derived class, finalizes the hash computation after the last data is processed by the cryptographic hash algorithm.

(繼承來源 HashAlgorithm)
Initialize()

初始化 MD5CryptoServiceProvider 的執行個體。Initializes an instance of MD5CryptoServiceProvider.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

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

計算輸入位元組陣列中指定區域的雜湊值,並將指定的輸入位元組陣列區域複製到指定的輸出位元組陣列區域。Computes the hash value for the specified region of the input byte array and copies the specified region of the input byte array to the specified region of the output byte array.

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

計算所指定位元組陣列中指定區域的雜湊值。Computes the hash value for the specified region of the specified byte array.

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

嘗試計算指定位元組陣列的雜湊值。Attempts to compute the hash value for the specified byte array.

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

在雜湊演算法處理最後一筆資料之後,嘗試完成雜湊計算。Attempts to finalize the hash computation after the last data is processed by the hash algorithm.

(繼承來源 HashAlgorithm)

明確介面實作

IDisposable.Dispose()

釋放 HashAlgorithm 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the HashAlgorithm and optionally releases the managed resources.

(繼承來源 HashAlgorithm)

適用於

另請參閱