473,785 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strong Password RegEx

UJ
Does anybody have lying around a Regex for a strong password (or a routine
to check it). I'd like the normal First character has to be a character,
total of 8 characters and has to have at least one number in it.

TIA - Jeff.
Aug 21 '06 #1
2 8317
Jeff,

That's not exactly "strong". It should be a minimum of eight
characters, as well as have one letter, one number, and one special
character (non alpha-numeric).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"UJ" <fr**@nowhere.c omwrote in message
news:Oc******** ******@TK2MSFTN GP06.phx.gbl...
Does anybody have lying around a Regex for a strong password (or a routine
to check it). I'd like the normal First character has to be a character,
total of 8 characters and has to have at least one number in it.

TIA - Jeff.


Aug 21 '06 #2
Since you don't care about it following a particular pattern, just
want to make sure it has a variety of characters it's easier to just
use a loop than to use Regex. Also for "strong" password you usually
want to test for a non-alphanumeric character as well.

HTH,

Sam

using System;

namespace CommandTest
{
public class StrongPassword
{
public static bool IsStrongPasswor d(string password)
{
if (password == null || password.Length < 8)
{
return false;
}

// custom rule, first char must be a letter
if (!Char.IsLetter (password[0]))
{
return false;
}

bool hasLetter = false;
bool hasDigit = false;
bool hasOther = false;

foreach(char c in password)
{
if (Char.IsLetter( c))
{
hasLetter = true;
}
else if (Char.IsDigit(c ))
{
hasDigit = true;
}
else
{
hasOther = true;
}
}

return hasLetter && hasDigit && hasOther;
}

public static void Test()
{
Test("hey");
Test("password" );
Test("pa$$word" );
Test("pa$$w0rd" );
}

public static void Test(string password)
{
Console.WriteLi ne("{0,-12}: {1}", password,
IsStrongPasswor d(password));
}

}
}
------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Mon, 21 Aug 2006 13:33:41 -0400, "UJ" <fr**@nowhere.c omwrote:
>Does anybody have lying around a Regex for a strong password (or a routine
to check it). I'd like the normal First character has to be a character,
total of 8 characters and has to have at least one number in it.

TIA - Jeff.
Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5881
by: John Morgan | last post by:
I urgently need tom use SP3a upgrade the instance of SQLServer200 MSDE runing on my local machine but I am having problems in doing so. My first problem is that when I start the set up procedure I get the message "A strong SA password is required for security reasons. Please use SAPWD switch to supply the same" Currently the sa password is Abc/def/ghk1
1
1455
by: Jimski | last post by:
Hi all, I am creating an assembly that will access a database to return record details. I need to deploy it to a 3rd Party and they will then be able to use the assembly in their code to access the methods contained within the assembly. As this assembly will effectively access the database then I need to provide some security to stop unwanted access.
1
250
by: jez123456 | last post by:
Hi I'm in the process of writing a program to ensure that a user will setup a strong password for a particular application. One of the requirements is:- A Strong Password must include characters from at least three of the following four categories... Uppercase characters (A though Z) Lowercase characters (a though z) Numeric digits (0 through 9)
1
1261
by: Henry Lee | last post by:
Hi, Our user complain about the strong password setting makes them hard to remember for ASP 2.0 web. Is there anyway to disable the setting which requires users must use strong password like #$% character ? Thanks, Henry
1
3433
by: jake | last post by:
Hi. I am building web apps in visual web developer 2005 express and SQL 2005 express. Users have complained about the strong password policy, so I would like to change it to somthing like at least 5 letters and 1 number. Thanks for the help in advance. -Jake
12
17602
by: adzir | last post by:
Hi, I need to validate password keyed in by the system users so that the password will contain only letters and numbers plus at least one capital letter. Exclude these symbols , < ? / * ( ) & ^ % $ # ! ~ ` " ' this is my code:
0
229
by: bienwell | last post by:
Thanks for your help. <wisccal@googlemail.comwrote in message news:60d1bad3-1e68-4a1f-bf2a-fd7b53153cd2@b64g2000hsa.googlegroups.com...
1
2847
by: Tom | last post by:
My unsigned DLL works in my project that references it as long as I set Copy Local = true. Now I have signed the DLL with the sn.exe generated keys but have not yet moved the DLL into the GAC. Can I use a strong named DLL outside the GAC with Copy Local = false by providing a reference to the public key? If yes to above, please tell me how to reference the public key within
9
6622
by: kummu4help | last post by:
can anyone give me a regex to validate the password with following conditions hope i am clear. i tried with ctype_alnum() function in php but it is accepting if all characters or either alphabet or digit. but i want to enforce atleast one alphabet and one digit should be in password can any one give me a regex for this pls.....
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.