473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 8302
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.com

"UJ" <fr**@nowhere.comwrote in message
news:Oc**************@TK2MSFTNGP06.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 IsStrongPassword(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.WriteLine("{0,-12}: {1}", password,
IsStrongPassword(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.comwrote:
>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
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...
1
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...
1
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...
1
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 #$%...
1
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...
12
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 , < ? / * ( ) &...
0
by: bienwell | last post by:
Thanks for your help. <wisccal@googlemail.comwrote in message news:60d1bad3-1e68-4a1f-bf2a-fd7b53153cd2@b64g2000hsa.googlegroups.com...
1
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. ...
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.