会员密码生成唯一的字母数字密码? [英] Membership Generate Password alphanumeric only password?

查看:427
本文介绍了会员密码生成唯一的字母数字密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用Membership.GeneratePassword返回只包含字母或数字字符的密码?默认的方法只能保证最低和非字母数字的密码不是最大数。


解决方案

 字符串NEWPASSWORD = Membership.GeneratePassword(15,0);
NEWPASSWORD = Regex.Replace(NEWPASSWORD,@[^ A-ZA-Z0-9],M =>9);

这经常EX pression将与数字字符替换9的所有非字母数字字符。

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 maximum number of non alphanumeric passwords.

解决方案

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.

这篇关于会员密码生成唯一的字母数字密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆