You must Sign In to post a response.
  • Category: .NET

    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#
  • #544646
    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
    hi,
    suing ASCII you con find out the password character,
    check following URL
    http://www.passwordmeter.com/

  • #544668
    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
    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
    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


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.