You must Sign In to post a response.

Uppercase letters, lowercase letters, numbers, and symbols for password

souce code for determine the number of uppercase letters, lowercase letters, numbers, and symbols for password in c#


Comments

Author: Nikhil Gaur30 Aug 2010 Member Level: Gold   Points : 2

you can do this by picking each character of password and then checking its ASCI number if it is between 48 and 57 then it is a number if it is between 65 and 90 it is a upper case character, if it is between 97 and 122 it will be lower case character otherwise it is a symbol...

Author: S.K.Sivakumar30 Aug 2010 Member Level: Gold   Points : 2

hi,
suing ASCII you con find out the password character,
check following URL
http://www.passwordmeter.com/

Author: Shivshanker Cheral30 Aug 2010 Member Level: Gold   Points : 2

Function to count number of characters you can send each character type to this function to count the number of characters.




//Function to count no.of occurences of Substring in Main string
public static int CharCount(String strSource,String strToCount)
{
int iCount=0;
int iPos=strSource.IndexOf(strToCount);
while(iPos!=-1)
{
iCount++;
strSource=strSource.Substring(iPos+1);
iPos=strSource.IndexOf(strToCount);
}
return iCount;
}



//Function to count no.of occurences of Substring in Main string
public static int CharCount(String strSource,String strToCount,bool
IgnoreCase)
{
if(IgnoreCase)
{
return CharCount(strSource.ToLower(),strToCount.ToLower());
}
else
{
return CharCount(strSource,strToCount);
}
}

Author: Hameed30 Aug 2010 Member Level: Silver   Points : 2

string pw = TextBox1.Text;
int convertedPw;
int counter = 0;

int uLetters = 0;
int lLetters = 0;

int numbers = 0;
int symbols = 0;

lblDetails.Text = "";


// #### >BEGIN< PROCESSING EACH CHARACTER ####
CharEnumerator charEnum = pw.GetEnumerator();
while (charEnum.MoveNext())
{
convertedPw = Convert.ToInt32(pw[counter]);

if ((convertedPw >= 65) && (convertedPw <= 90))
{
uLetters++;
}

if ((convertedPw >= 97) && (convertedPw <= 122))
{
lLetters++;
}

if ((convertedPw >= 48) && (convertedPw <= 57))
{
numbers++;
}

if ((convertedPw >= 33) && (convertedPw <= 47))
{
symbols++;
}

if ((convertedPw >= 58) && (convertedPw <= 64))
{
symbols++;
}

if ((convertedPw >= 91) && (convertedPw <= 96))
{
symbols++;
}

if ((convertedPw >= 123) && (convertedPw <= 126))
{
symbols++;
}

counter++;
}
// #### >END< PROCESSING EACH CHARACTER ####

lblDetails.Text += "Upper Case Letters: " + uLetters.ToString() + "\n";
lblDetails.Text += "Lower Case Letters: " + lLetters.ToString() + "\n";
lblDetails.Text += "Numbers: " + numbers.ToString() + "\n";
lblDetails.Text += "Symbols: " + symbols.ToString() + "\n";

Author: Paritosh Mohapatra30 Aug 2010 Member Level: Gold   Points : 2

Hi

You can use AjaxControlToolkit's PasswordStrength control for this purpose.

Please check the following link for a sample:

http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/PasswordStrength/PasswordStrength.aspx

Thanks & Regards
Paritosh Mohpaatra


Sign In to post your comments