1

I am using the following Membership.ValidateUser method to validate user with SHA-1 hashed password, but it always returns false.

If I put a non-hashed password, in other words, plain password, then it returns true. I wonder what I am doing wrong.

Code Implementation

var isAuthenticated = Membership.ValidateUser(username, userpassword);

Web.Config

<membership defaultProvider="ASPMembershipProvider" hashAlgorithmType="SHA1">
      <providers>
        <clear/>
        <add name="ASPMembershipProvider" 
         applicationName="ASPMember" 
         connectionStringName="ASPConnectionString" 
         type="System.Web.Security.SqlMembershipProvider" 
         enablePasswordRetrieval="false" 
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         maxInvalidPasswordAttempts="5" 
         passwordAttemptWindow="25" 
         minRequiredPasswordLength="5" 
         minRequiredNonalphanumericCharacters="0" 
         passwordStrengthRegularExpression="" 
         passwordFormat="Hashed"  />
      </providers>
</membership>
casillas
  • 16,351
  • 19
  • 115
  • 215

0 Answers0