Forums » .NET » .NET »

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


Posted Date: 30 Aug 2010      Posted By:: Hameed Profile photo    Member Level: Silver    Member Rank: 3258     Points: 1   Responses: 5



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



Responses

#544646    Author: Nikhil Gaur      Member Level: Gold      Member Rank: 164     Date: 30/Aug/2010   Rating: 2 out of 52 out of 5     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...

Thanks & Regards
NIks


 
#544653    Author: S.K.Sivakumar      Member Level: Gold      Member Rank: 941     Date: 30/Aug/2010   Rating: 2 out of 52 out of 5     Points: 2

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


 
#544668    Author: Shivshanker Cheral      Member Level: Gold      Member Rank: 25     Date: 30/Aug/2010   Rating: 2 out of 52 out of 5     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);
}
}



Thanks
Shivshanker Cheral
"If you share your assets (money etc..) it will decrease, But if you share your knowledge it will increase!!! ".





 
#544669    Author: Hameed      Member Level: Silver      Member Rank: 3258     Date: 30/Aug/2010   Rating: 2 out of 52 out of 5     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";


 
#544681    Author: Paritosh Mohapatra      Member Level: Gold      Member Rank: 9     Date: 30/Aug/2010   Rating: 2 out of 52 out of 5     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


Thanks & Regards
Paritosh Mohapatra
Microsoft MVP (ASP.Net/IIS)
DotNetSpider MVM


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Getting Error during sending sms using GSMCOMM Library in C#
Previous : Email
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India