试试
SHA1 sha1 = SHA1.Create();
 最后的结果= sha1.ComputeHash( Encoding.Unicode.GetBytes( xsc001 ) );

解决方案 »

  1.   

    试试
    SHA1 sha1 = SHA1.Create();
     最后的结果= sha1.ComputeHash( Encoding.Unicode.GetBytes( xsc001 ) );
    能给我个完整的代码吗?
      

  2.   

    <%@ Page Language="C#" autoeventwireup="true" %>
    <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 (sha1.Checked)
                   {
                      hashMethod = "SHA1";
                   }
                   else
                   {
                      hashMethod = "MD5";
                   }
        
                   string hashedPassword =
                      FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, hashMethod);
        
                   result.Text="&lt;credentials passwordFormat=\"" + hashMethod +"\"&gt;<br>" +
                      "&nbsp;&nbsp;&nbsp;&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>
                <tbody>
                   <tr>
                      <td>New User Name:</td>
                      <td><asp:TextBox id="userName" runat="server"></asp:TextBox></td>
                      <td><asp:RequiredFieldValidator id="userNameRequiredValidator" runat="server" 
                         ErrorMessage="User name required" ControlToValidate="userName"></asp:RequiredFieldValidator></td>
                   </tr>
                   <tr>
                      <td>Password: </td>
                      <td><asp:TextBox id="password" runat="server" TextMode="Password"></asp:TextBox></td>
                      <td><asp:RequiredFieldValidator id="passwordRequiredValidator" runat="server" 
                         ErrorMessage="Password required" ControlToValidate="password"></asp:RequiredFieldValidator></td>
                   </tr>
                   <tr>
                      <td>Repeat Password: </td>
                      <td><asp:TextBox id="repeatPassword" runat="server" TextMode="Password"></asp:TextBox></td>
                      <td><asp:CompareValidator id="passwordCompareValidator" runat="server" 
                         ErrorMessage="Password does not match" ControlToValidate="repeatPassword" 
                         ControlToCompare="password"></asp:CompareValidator></td>
                   </tr>
                   <tr>
                      <td>Hash function: </td>
                      <td align="middle"><asp:RadioButton id="sha1" runat="server" GroupName="HashType" 
                         Text="SHA1"></asp:RadioButton>
                      <asp:RadioButton id="md5" runat="server" GroupName="HashType" Text="MD5"></asp:RadioButton></td>
                   </tr>
                   <tr>
                      <td align="middle" colspan="2">
                      <asp:Button id="hashPassword" onclick="HashPassword_Click" runat="server" Text="Hash Password">
                      </asp:Button>&nbsp;&nbsp; 
                      <asp:Button id="cancel" onclick="Cancel_Click" runat="server" Text="Cancel" CausesValidation="false">
                      </asp:Button></td>
                   </tr>
                </tbody>
             </table>
             <p><asp:Label id="result" runat="server"></asp:Label></p>
          </form>
       </body>
    </html>
      

  3.   

    sha1,md5加密我用了,xsc001加密后不是我想要的那个