Membership Generate Password alphanumeric only password?

前端 未结 7 2121
独厮守ぢ
独厮守ぢ 2020-12-28 13:11

How can I use Membership.GeneratePassword to return a password that ONLY contains alpha or numeric characters? The default method will only guarantee a minimum and not a max

7条回答
  •  一整个雨季
    2020-12-28 13:16

    string newPassword = Membership.GeneratePassword(15, 0);
    newPassword = Regex.Replace(newPassword, @"[^a-zA-Z0-9]", m => "9" );
    

    This regular expression will replace all non alphanumeric characters with the numeric character 9.

提交回复
热议问题