FormsAuthPasswordFormat 列舉

定義

定義儲存密碼的加密格式。

public enum class FormsAuthPasswordFormat
public enum FormsAuthPasswordFormat
type FormsAuthPasswordFormat = 
Public Enum FormsAuthPasswordFormat
繼承
FormsAuthPasswordFormat

欄位

Clear 0

指定不加密的密碼。 這個欄位為常數。

MD5 2

指定使用 MD5 雜湊演算法加密密碼。 這個欄位為常數。

由於 MD5 的衝突問題,Microsoft 建議您使用以 SHA256 或更好的加密方式為基礎的安全性模型。

SHA1 1

指定使用 SHA1 雜湊演算法加密密碼。 這個欄位為常數。

由於 SHA1 的衝突問題,Microsoft 建議您使用以 SHA256 或更好的加密方式為基礎的安全性模型。

SHA256 3

指定使用 SHA256 雜湊演算法加密密碼。 這個欄位為常數。

SHA384 4

指定使用 SHA384 雜湊演算法加密密碼。 這個欄位為常數。

SHA512 5

指定使用 SHA512 雜湊演算法加密密碼。 這個欄位為常數。

範例

下列程式碼範例示範如何使用 FormsAuthPasswordFormat 列舉。 請參閱類別主題中的 FormsAuthenticationUserCollection 程式碼範例,以瞭解如何取得集合。

// Get the current PasswordFormat property value.
FormsAuthPasswordFormat currentPasswordFormat =
formsAuthenticationCredentials.PasswordFormat;

// Set the PasswordFormat property value.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
formsAuthenticationCredentials.PasswordFormat = 
    FormsAuthPasswordFormat.SHA1;
' Get the current PasswordFormat property value.
  Dim currentPasswordFormat _
  As FormsAuthPasswordFormat = _
  formsAuthenticationCredentials.PasswordFormat


' Set the PasswordFormat property value.
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
  formsAuthenticationCredentials.PasswordFormat = _
  FormsAuthPasswordFormat.SHA1

備註

若要以程式設計方式設定用來將密碼儲存在 Web 應用程式中的加密類型,請使用 類別 AuthenticationSection 。 在處理驗證票證時,也會在內部 FormsAuthentication 使用此類別。

適用於