title: ASP.Net - How to Encrypt password before login while using Login Control
body: <p>I'm using the ASP.Net Login control to login a web application. When the user submits the form, I want to call a function to encrypt the password before ASP.Net sends the information for authentication.</p>
  
  <p>I tried to add a Customer Validator on the password field and if the password is not empty, the Password.Text will be replaced with the encrypted value. However, it seems ASP.Net still sent the original password for authentication. </p>
  
  <p>I also tried adding a onClick event on the login button to encrypt the password but ASP.Net still sent the original password for authentication.</p>
  
  <p>Is there a way to do this? Thank you!</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I'm sorry for not making this clear. What I need is to encrypt the password at Server Side.</p>
  
  <p>I'm not using ASP.Net Membership to encrypt or hash the password while registering a user. The passwordFormat property has been set to "Clear".</p>
  
  <p>What I am doing is:</p>
  
  <ol>
  <li>While a new user registers, I use a customized function to encrypt the password and save it to database.</li>
  <li>When a user tries to login, I want to use the same function to encrypt the password entered by the user and let ASP.Net to authenticate the user.</li>
  </ol>
  
  <p>The problem I'm having is I can't find a way to call the encrypt function before ASP.Net initiate the authentication process.</p>
  
  <p>Hope this makes sense. Thank you.</p>
  
  <p>Allen</p>