哪个是需要实现验证密码的最佳设计模式? [英] Which is the best design pattern that need to be impletmented validating password?

查看:130
本文介绍了哪个是需要实现验证密码的最佳设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要根据以下要求验证输入密码:



1.密码不得包含用户名。

2.密码不应重复以前的密码。

3.密码至少应包含数字。



我主要需要在代码中实现最佳设计模式的信息,以实现解耦并适合测试驱动开发。



你能支持一个例子吗?





谢谢。

Hi,

I need to validate the input password for the given below requirement:

1. The password must not contain username.
2. The password should not repeat previous passwords.
3. The password should atleast contain a numeral.

I mainly need information on the best design pattern to be implemented in the code to achieve decoupling and suitable for test driven development.

Can you please support with an example?


Thanks.

推荐答案

如果您非常热衷于解耦和可测试性,那么请尝试应用Chain of Responsibility Design Pattern。



使用责任链设计模式概念来执行复杂数据的验证和处理 [ ^ ]



了解并实施C#中的责任链模式 [ ^ ]
If you are much keen on Decoupling and Testability , then try to apply Chain of Responsibility Design Pattern.

Using the Chain Of Responsibility Design Pattern Concepts to Perform Validation and Processing of Complex Data[^]

Understanding and Implementing Chain of Responsibility Pattern in C#[^]


上述大部分情况都可以使用正则表达式。请查看下面提到的链接以获取更多信息。



验证C#和ASP.NET中的强密码



使用正则表达式和ASP.Net Re实现密码策略gularExpression Validator
Most of the above cases you can use regular expressions.Please check below mentioned links for more info.

Validate strong passwords in C# and ASP.NET

Implement Password Policy using Regular Expressions and ASP.Net RegularExpression Validator


尝试

强密码验证 [ ^ ]

www.codeproject.com/Articles/49527/How-to-Use-the-ASP-NET-Validation-Control-to-Valid [ ^ ]


这篇关于哪个是需要实现验证密码的最佳设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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