Results 1 to 7 of 7

Thread: Random Password Maker

  1. #1

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Random Password Maker

    Hi all,
    I was just reading my c# book on some functions and spotted the random function, and I came up with makeing a small password generator. it very basic but seems to do the tick the code is also small anyway thought I share it with you. Hope you find it usfull comments are welcome.

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            //Random chars to pick a password from
            const string iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Random Rnd = new Random();
                StringBuilder sb = new StringBuilder();
    
                for (int x = 0; x < 10; x++)
                {
                    //Pull out a random number
                    int RndNum = Rnd.Next(iChars.Length - 1);
                    //Build the random string.
                    sb.Append(iChars[RndNum]);
                }
                //Display random string
                MessageBox.Show("Here is your random password: " + sb.ToString());
            }
        }
    }

  2. #2
    Lively Member
    Join Date
    Feb 2008
    Posts
    107

    Re: Random Password Maker

    tanx

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    17

    Re: Random Password Maker

    Kl, Imma save it for later use in the future

  4. #4
    Lively Member
    Join Date
    Feb 2008
    Posts
    107

    Re: Random Password Maker

    Hi would this code generate the same password twice? if not is there something i can add to this code to stop it doing so?

    regards anton.

  5. #5

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: Random Password Maker

    Umm I am not sure if this is the correct way but maybe you can fill an array and check if the item is already found if so generate a new password. I am faced with the same problum now cos I updated my password generator and will upload today some time.

  6. #6

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: Random Password Maker

    Hi
    This is an update of the Random Password Maker, it now has a gui so it easyer to use, you can set the length of the password to create and the number of passwords to create, You also have options to create Alpha, AlphaNumeric, or Numeric only passwords, there also a option to copy selected password to clipboard and option to save passwords. Hope you like the update.

    Thanks goes to Max Peck for helping me with the random problum.

    Attached Files Attached Files

  7. #7
    Lively Member
    Join Date
    Feb 2008
    Posts
    107

    Re: Random Password Maker

    thanks for the share man this will be very useful, i am trying to make it so that the password's are generated to a list using file append text and a while(true) loop. problem is the while loop is just keep goign dn wont stop iv tryed break; with button click's ect, problem is i can click a button of the program says not responding. i know that the program is still running because my text file witch i am writing the passwords to keeps going up in size. i have been told to try using threads ect nt to sure how but im fairly new to c#.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width