Custom password calculation

If you want to calculate the passwords in your own way, follow this procedure. You can find more information in the Customizing providers.

  1. Create a new class in the App_Code folder.

  2. Set the class to inherit from the UserInfoProvider class.

  3. Override the GetPasswordHashInternal method.

  4. Add the RegisterCustomProvider assembly attribute above the class declaration to register the provider.

    
    
    
     using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Web;
    
     using CMS;
     using CMS.Helpers;
     using CMS.Membership;
    
     // Registers the custom provider
     [assembly: RegisterCustomProvider(typeof(MyUserInfoProvider))]
    
     /// <summary>
     /// Customized UserInfoProvider for password calculation.
     /// </summary>
     public class MyUserInfoProvider : UserInfoProvider
     {
         protected override string GetPasswordHashInternal(string password, string passwordFormat, string salt)
         {
             return SecurityHelper.GetSHA1Hash(password + "CustomSalt");
         }
     }
    
    
     

The system now uses the customized provider (MyUserInfoProvider) instead of the default one.