Login Register






Random Password Generator [C#] filter_list
Author
Message
Random Password Generator [C#] #1
Hello guys, I've made a simple password generator which uses a list of strings to grab random chars and a random number generator that gives us the index numbers for those random chars in the string. Since you can't pick random char from string like in python E.g:

Code:
import random items = 'abcdefghijklmnopqrstuvwxyz' random.choice(items)

As I was unable to find a suitable function to do it in C#, but I did make an alternative, Here's my complete code:

Code:
//Coded By Ex094 Random rnd = new Random(); //To Generate Random Numbers for string Index string password = ""; //Variable to store the final Password string passlist = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,./'[]~!@#$%^&*()_+=-|}{:?><"; Console.WriteLine ("Enter Password Length:"); string usrleng = Console.ReadLine(); //Get length from user in the form of string int length = Convert.ToInt32(usrleng); //Convert the string to an int for (int x = 0; x < length; x++) //Loop accroding to the length of the password { int pick = rnd.Next(1, passlist.Length); //Generate index number (Random) password += passlist[pick]; //Get the random item from the passlist based on the random index number } Console.WriteLine("Your Generated Password Is: {0}", password); //Print the password

Here's an example output of my program with Password length 15:

Code:
^CSFcogv5:{DhQ]

This is my first C# program so any suggestions will be appreciated Smile

Regards,
Ex094
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Random Password Generator [C#] #2
Nice snippet. Now to make this safe you can collect some entropy before using a pseudo number generator. I am not sure how hard that is, I have never done it before. But I think you might find something on the web.

Edit: I already found something: http://upokecenter.dreamhosters.com/arti...ator-in-c/
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Random Password Generator [C#] #3
@Deque Thank you and that is a good resource you provided there bookmarked, May I ask if there's any pseudo code for that code (IN the resource site) I'm having a little problem understanding the code

Edit: Entropy is indeed an excellent thing introduced in Information theory, this really caught my attention and is really interesting Smile Thanks for pointing this deque! Cheers
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Random Password Generator [C#] #4
(06-21-2013, 05:01 AM)Ex094 Wrote: @Deque Thank you and that is a good resource you provided there bookmarked, May I ask if there's any pseudo code for that code (IN the resource site) I'm having a little problem understanding the code

No, it is just a source sample. The missing indentation makes it hard to read.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Random Password Generator [C#] #5
e possibile testare grazie

Reply