一个明智的PasswordStrengthRegularEx pression [英] A sensible PasswordStrengthRegularExpression

查看:233
本文介绍了一个明智的PasswordStrengthRegularEx pression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用标准的ASP.NET身份验证提供者(AspNetSqlMembershipProvider因为它发生)和defualt密码强度的要求是我们需要有点过分。

We're using the standard ASP.NET authentication provider (AspNetSqlMembershipProvider as it happens) and the defualt password strength requirement is a little excessive for our needs.

我们要求我们的用户输入的密码是字母数字至少(即,字母和至少一个数字强制性的,大小写混合和非字母数字字符,如果用户要求这样做)。

We require our users to enter a password that is alphanumeric at least (i.e, letters and at least one number mandatory, mixed case and non-alphanumeric characters if the user so desires).

任何人都可以提出什么PasswordStrengthRegularEx pression设置将实现这一目标?

Can anyone suggest what PasswordStrengthRegularExpression setting would achieve this?

此外,我们如何能够控制显示给用户的错误信息,如果他们试图使用密码失败的常规前pression检查?

Also, how can we control the error message shown to the user if the password they try to use fails the regular expression check?

据发现, minRequiredNonalphanumericCharacters 属性必须设置为 0 ,否则该设置将覆盖的任何常规的前$即使用对$ pssion

It was found that the minRequiredNonalphanumericCharacters property must be set to 0, otherwise this setting overrides any regular expression that is used

推荐答案

下面是一个正则表达式,可以让所有的字符,至少需要一个号码,至少需要6个字符。

Here is a regex that allows all characters and requires at least one number and requiring at least 6 characters.

^.*(?=.{6,})(?=.*\d).*$

如果您想了解更多,或定义简单的改变更少的字符(?= {6})来选择你想作为一个最小的字符数。

If you want more or less characters defined simply change (?=.{6,}) to reflect the number of characters you want as a minimum.

这篇关于一个明智的PasswordStrengthRegularEx pression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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