how to generate random password in asp.net using c#

Advertisement
In this article I will explain you how to generate random password in asp.net using c#.
Create one method and call that method in Insert mode or update mode. It generate random password.

Check the below code Example How to use.

 public static string CreateRandomPassword(int PasswordLength)
        {
            string _allowedChars = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ";
            Random randNum = new Random();
            char[] chars = new char[PasswordLength];
            int allowedCharCount = _allowedChars.Length;
            for (int i = 0; i < PasswordLength; i++)
            {
                chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
            }
            return new string(chars);
        }




call this method in Insert mode or update mode,based upon your requirement.

If you give 8 meants it will show like this ZeXdjOdx

string pwd = CreateRandomPassword(8);

Advertisements
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

16 comments:

  1. Hi admin, i went through article. As we all know, .net is most popular programming language and it offer huge career prospects for talented professionals. It’s totally awesome, keep on updating your blog with such awesome information. .Net Training in Chennai

    ReplyDelete
  2. I have read your blog its very attractive and impressive. I like it your blog.

    Dot Net Training in Chennai Dot Net Training in Chennai .Net Online Training .Net Online Training Dot Net Training in Chennai Dot Net Training in Chennai


    Dot Net Online Training Dot Net Online Training LINQ Online Training LINQ Online Training ASP.NET Online Training ASP.NET Online Training

    ReplyDelete
  3. The best thing is that your blog really informative thanks for your great information!
    erp in chennai

    ReplyDelete
  4. Good one, very informative.. thanks for sharing your views and ideas.. it is very useful to me.. thanks once again.

    Dot Net Training in chennai | Dot Net Training institute in chennai

    ReplyDelete
  5. Hi, am a big follower of your blog. I am really happy to found such a helpful and fascinating post that is written in well manner.

    mobile website builder

    ReplyDelete
  6. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..

    white label website builder

    ReplyDelete
  7. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts
    python training institute in marathahalli | python training institute in btm

    ReplyDelete
  8. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    excel advanced excel training in bangalore | Devops Training in Chennai

    ReplyDelete
  9. I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.

    Java training in Bangalore | Java training in Marathahalli

    Java training in Bangalore | Java training in Btm layout

    Java training in Bangalore |Java training in Rajaji nagar

    ReplyDelete
  10. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.

    AWS Training in Bangalore | Amazon Web Services Training in bangalore , india

    AWS Training in pune | Amazon Web Services Training in Pune, india

    AWS Training in Chennai|Amazon Web Services Training in Chennai,India


    aws online training and certification | amazon web services online training ,india

    ReplyDelete
  11. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    ReplyDelete