FormsAuthentication.HashPasswordForStoringInConfigFile メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FormsAuthentication.HashPasswordForStoringInConfigFile メソッドの意味・解説 

FormsAuthentication.HashPasswordForStoringInConfigFile メソッド

指定したパスワードハッシュ アルゴリズム基づいて構成ファイル格納できるハッシュ パスワード生成します

名前空間: System.Web.Security
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Shared Function HashPasswordForStoringInConfigFile
 ( _
    password As String, _
    passwordFormat As String _
) As String
Dim password As String
Dim passwordFormat As String
Dim returnValue As String

returnValue = FormsAuthentication.HashPasswordForStoringInConfigFile(password, passwordFormat)
public static string HashPasswordForStoringInConfigFile
 (
    string password,
    string passwordFormat
)
public:
static String^ HashPasswordForStoringInConfigFile (
    String^ password, 
    String^ passwordFormat
)
public static String HashPasswordForStoringInConfigFile
 (
    String password, 
    String passwordFormat
)
public static function HashPasswordForStoringInConfigFile
 (
    password : String, 
    passwordFormat : String
) : String

パラメータ

password

ハッシュするパスワード

passwordFormat

使用するハッシュ アルゴリズムpasswordFormat は、FormsAuthPasswordFormat 列挙値の 1 つを表す Stringなります

戻り値
ハッシュされたパスワード

例外例外
例外種類条件

ArgumentNullException

password is null 参照 (Visual Basic では Nothing)

または

passwordFormatnull 参照 (Visual Basic では Nothing) です。

ArgumentException

passwordFormat有効な FormsAuthPasswordFormat 値ではありません。

解説解説
使用例使用例

ユーザー名パスワード、およびハッシュ タイプ入力値として受け取りユーザー定義とハッシュされたパスワード格納され構成ファイルcredentials セクション表示するコード例次に示します

<%@ Page Language="VB" %>
<html>
   <head>
      <script runat="server">
         Sub Cancel_Click(sender As Object,
 e As EventArgs)
            userName.Text = ""
            password.Text = ""
            repeatPassword.Text = ""
            result.Text = ""
         End Sub
    
         Sub HashPassword_Click(sender As Object,
 e As EventArgs)
            If Page.IsValid Then
               Dim hashMethod As String
 = ""

               If md5.Checked Then
                  hashMethod = "MD5"
               Else
                  hashMethod = "SHA1"
               End If
    
               Dim hashedPassword As String
 = _
                  FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text,
 hashMethod)
    
               result.Text = "&lt;credentials passwordFormat="""
 & hashMethod & _
                 """&gt;<br>"
 & "  &lt;user name=""" & userName.Text
 & """ password=""" & _
                 hashedPassword & """
 /&gt;<br>" & "&lt;/credentials&gt;"
            Else
               result.Text = "There was an error on the page."
            End If
         End Sub
      </script>
   </head>

   <body>
      <form runat="server">
         <p>This form displays the results of the FormsAuthentication.HashPasswordForStoringInConfigFile
         method.<br>The user name and hashed password can
 be stored in a &lt;credentials&gt; node
         in the Web.config file.</p>
         <table cellpadding=2>
            <tbody>
               <tr>
                  <td>New User Name:</td>
                  <td><asp:TextBox id="userName"
 runat="server" /></td>
                  <td><asp:RequiredFieldValidator id="userNameRequiredValidator"
 
                        runat="server" ErrorMessage="User
 name required" 
                        ControlToValidate="userName"
 /></td>
               </tr>
               <tr>
                  <td>Password: </td>
                  <td><asp:TextBox id="password"
 runat="server" TextMode="Password"
 /></td>
                  <td><asp:RequiredFieldValidator id="passwordRequiredValidator"
 
                        runat="server" ErrorMessage="Password
 required" 
                        ControlToValidate="password"
 /></td>
               </tr>
               <tr>
                  <td>Repeat Password: </td>
                  <td><asp:TextBox id="repeatPassword"
 runat="server" TextMode="Password"
 /></td>
                  <td><asp:RequiredFieldValidator id="repeatPasswordRequiredValidator"
 
                        runat="server" ErrorMessage="Password
 confirmation required" 
                        ControlToValidate="repeatPassword"
 />
                      <asp:CompareValidator id="passwordCompareValidator"
 runat="server" 
                        ErrorMessage="Password does not match"
 
                        ControlToValidate="repeatPassword"
 
                        ControlToCompare="password"
 /></td>
               </tr>
               <tr>
                  <td>Hash function:</td>
                  <td align="middle">
                     <asp:RadioButton id="sha1"
 runat="server" GroupName="HashType"
 
                                      Text="SHA1"
 />
                     <asp:RadioButton id="md5"
 runat="server" GroupName="HashType"
 
                                      Text="MD5" />
                  </td>
               </tr>
               <tr>
                  <td align="middle" colspan="2">
                    <asp:Button id="hashPassword"
 onclick="HashPassword_Click" 
                                runat="server" Text="Hash
 Password" />&nbsp;&nbsp; 
                    <asp:Button id="cancel" onclick="Cancel_Click"
 runat="server" 
                                Text="Cancel" CausesValidation="false"
 />
                  </td>
               </tr>
            </tbody>
         </table>

         <pre><asp:Label id="result" runat="server"></asp:Label></pre>
      </form>
   </body>
</html>
<%@ Page Language="C#" %>
<html>
   <head>
      <script runat="server">
         void Cancel_Click(object sender, EventArgs e)
         {
            userName.Text = "";
            password.Text = "";
            repeatPassword.Text = "";
            result.Text = "";
         }
    
         void HashPassword_Click(object sender, EventArgs e)
         {
            if (Page.IsValid)
            {
               string hashMethod = "";

               if (md5.Checked)
               {
                  hashMethod = "MD5";
               }
               else
               {
                  hashMethod = "SHA1";
               }
    
               string hashedPassword =
                  FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text,
 hashMethod);
    
               result.Text = "&lt;credentials passwordFormat=\""
 + hashMethod +"\"&gt;<br>" +
                  "  &lt;user name=\"" + userName.Text + "\"
 password=\"" +
                  hashedPassword + "\" /&gt;<br>" + "&lt;/credentials&gt;";
            }
            else
            {
               result.Text = "There was an error on the page.";
            }
         }
      </script>
   </head>

   <body>
      <form runat="server">
         <p>This form displays the results of the FormsAuthentication.HashPasswordForStoringInConfigFile
         method.<br>The user name and hashed password can be stored in
 a &lt;credentials&gt; node
         in the Web.config file.</p>
         <table cellpadding=2>
            <tbody>
               <tr>
                  <td>New User Name:</td>
                  <td><asp:TextBox id="userName" runat="server"
 /></td>
                  <td><asp:RequiredFieldValidator id="userNameRequiredValidator"
 
                        runat="server" ErrorMessage="User name required"
 
                        ControlToValidate="userName" /></td>
               </tr>
               <tr>
                  <td>Password: </td>
                  <td><asp:TextBox id="password" runat="server"
 TextMode="Password" /></td>
                  <td><asp:RequiredFieldValidator id="passwordRequiredValidator"
 
                        runat="server" ErrorMessage="Password required"
 
                        ControlToValidate="password" /></td>
               </tr>
               <tr>
                  <td>Repeat Password: </td>
                  <td><asp:TextBox id="repeatPassword" runat="server"
 TextMode="Password" /></td>
                  <td><asp:RequiredFieldValidator id="repeatPasswordRequiredValidator"
 
                        runat="server" ErrorMessage="Password confirmation
 required" 
                        ControlToValidate="repeatPassword" />
                      <asp:CompareValidator id="passwordCompareValidator"
 runat="server" 
                        ErrorMessage="Password does not match" 
                        ControlToValidate="repeatPassword" 
                        ControlToCompare="password" /></td>
               </tr>
               <tr>
                  <td>Hash function:</td>
                  <td align="middle">
                     <asp:RadioButton id="sha1" runat="server"
 GroupName="HashType" 
                                      Text="SHA1" />
                     <asp:RadioButton id="md5" runat="server"
 GroupName="HashType" 
                                      Text="MD5" />
                  </td>
               </tr>
               <tr>
                  <td align="middle" colspan="2">
                    <asp:Button id="hashPassword" onclick="HashPassword_Click"
 
                                runat="server" Text="Hash Password"
 />&nbsp;&nbsp; 
                    <asp:Button id="cancel" onclick="Cancel_Click"
 runat="server" 
                                Text="Cancel" CausesValidation="false"
 />
                  </td>
               </tr>
            </tbody>
         </table>

         <pre><asp:Label id="result" runat="server"></asp:Label></pre>
      </form>
   </body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からFormsAuthentication.HashPasswordForStoringInConfigFile メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFormsAuthentication.HashPasswordForStoringInConfigFile メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFormsAuthentication.HashPasswordForStoringInConfigFile メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

FormsAuthentication.HashPasswordForStoringInConfigFile メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FormsAuthentication.HashPasswordForStoringInConfigFile メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS