Post: Random Password Generator (Download & Source)
08-07-2014, 04:44 PM #1
Default Avatar
Brad
Guest
(adsbygoogle = window.adsbygoogle || []).push({}); This one one of my first main attempts at making a program in C# after having experience with PHP and Javascript. Here I have made a random password generator.

You must login or register to view this content.

Source
    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (letters.Checked == true || specialcharacters.Checked == true || numbers.Checked == true)
{
GeneratePassword();
}
else
{
alertMessage(3);
}

}

private void GeneratePassword()
{
List<string> CheckedBoxes = new List<string>();

if (letters.Checked) CheckedBoxes.Add("letters");
if (specialcharacters.Checked) CheckedBoxes.Add("specialcharacters");
if (numbers.Checked) CheckedBoxes.Add("numbers");
string[] CheckBoxes = CheckedBoxes.ToArray();

string GeneratedString = "";

Random random = new Random();
char[] alphas = "dFoQBNTfDeRmrHiUlSzCVJWLKcqXwOxEnMbsazkpYPhjtgIuZGyA".ToArray(); // Alphabet, lower and upper
char[] specChar = "!£$%^&*()_+-={}[]Angry~;'#<>,.?/".ToArray();
int ran;

for (int i = 0; i < password_length.Value; i++)
{
ran = random.Next(1, 1+CheckBoxes.Length);
//Console.WriteLine(CheckBoxes[ran-1]);

switch (CheckBoxes[ran-1])
{
case "letters":
ran = random.Next(1, alphas.Length);
GeneratedString += alphas[ran-1];
break;
case "numbers":
ran = random.Next(0, 10);
GeneratedString += ran;
break;
case "specialcharacters":
ran = random.Next(1, specChar.Length);
GeneratedString += specChar[ran - 1];
break;
}
generated_password.Text = GeneratedString;
}
}

private void label3_Click(object sender, EventArgs e)
{
if (generated_password.Text != "")
{
System.Windows.Forms.Clipboard.SetText(generated_password.Text);
alertMessage(1);
}
else
{
alertMessage(2);
}
}

public void alertMessage(int id)
{
switch (id)
{
case 1:
MessageBox.Show("Password Copied To Clipboard", "Information..", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
break;
case 2:
MessageBox.Show("No Content To Copy To Clipboard", "Information..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
break;
case 3:
MessageBox.Show("Please Select a Checkbox", "Information..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
break;
}
}
}
}



Program Download:
You must login or register to view this content.
Source Download:
You must login or register to view this content.
Last edited by Brad ; 08-07-2014 at 05:18 PM.

The following 6 users say thank you to Brad for this useful post:

John, Dan, Pichu, SiLLiKaLaX
08-07-2014, 04:51 PM #2
Citadel
Samurai Poster
Or you can use You must login or register to view this content. then check it on You must login or register to view this content.
08-07-2014, 04:58 PM #3
Default Avatar
Brad
Guest
Originally posted by Citadel View Post
Or you can use You must login or register to view this content. then check it on You must login or register to view this content.


Or I made it myself because I want to learn C#..


FYI, the password I just generated with my tool "+fbp(7[[0U@&G96Z" gave this result:

You must login or register to view this content.
08-07-2014, 05:03 PM #4
Citadel
Samurai Poster
Originally posted by Brad View Post
Or I made it myself because I want to learn C#..


FYI, the password I just generated with my tool "+fbp(7[[0U@&G96Z" gave this result:

You must login or register to view this content.


You must login or register to view this content.
That was a password from the site I linked :troll:
08-07-2014, 05:13 PM #5
Default Avatar
Brad
Guest
Originally posted by Citadel View Post
You must login or register to view this content.
That was a password from the site I linked :troll:


Here's another from my tool :carling:

You must login or register to view this content.

The following 2 users say thank you to Brad for this useful post:

08-07-2014, 05:14 PM #6
Dan
I'm a god.
Originally posted by Brad View Post
snip


If you're getting into programming, be sure to check this out.

You must login or register to view this content.

The following 2 users say thank you to Dan for this useful post:

08-07-2014, 05:19 PM #7
Default Avatar
Brad
Guest
Originally posted by Dan View Post
If you're getting into programming, be sure to check this out.

You must login or register to view this content.


Thanks! I'll get right on that!

The following user thanked Brad for this useful post:

08-08-2014, 10:09 PM #8
Dan
I'm a god.
Originally posted by Brad View Post
Thanks! I'll get right on that!


You can find those in the 4chan.org/g/ DPT's (Daily programming threads).
08-09-2014, 12:18 AM #9
Pichu
RIP PICHU.
Originally posted by Brad View Post
This one one of my first main attempts at making a program in C# after having experience with PHP and Javascript. Here I have made a random password generator.

You must login or register to view this content.

Source
    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (letters.Checked == true || specialcharacters.Checked == true || numbers.Checked == true)
{
GeneratePassword();
}
else
{
alertMessage(3);
}

}

private void GeneratePassword()
{
List<string> CheckedBoxes = new List<string>();

if (letters.Checked) CheckedBoxes.Add("letters");
if (specialcharacters.Checked) CheckedBoxes.Add("specialcharacters");
if (numbers.Checked) CheckedBoxes.Add("numbers");
string[] CheckBoxes = CheckedBoxes.ToArray();

string GeneratedString = "";

Random random = new Random();
char[] alphas = "dFoQBNTfDeRmrHiUlSzCVJWLKcqXwOxEnMbsazkpYPhjtgIuZGyA".ToArray(); // Alphabet, lower and upper
char[] specChar = "!£$%^&*()_+-={}[]Angry~;'#<>,.?/".ToArray();
int ran;

for (int i = 0; i < password_length.Value; i++)
{
ran = random.Next(1, 1+CheckBoxes.Length);
//Console.WriteLine(CheckBoxes[ran-1]);

switch (CheckBoxes[ran-1])
{
case "letters":
ran = random.Next(1, alphas.Length);
GeneratedString += alphas[ran-1];
break;
case "numbers":
ran = random.Next(0, 10);
GeneratedString += ran;
break;
case "specialcharacters":
ran = random.Next(1, specChar.Length);
GeneratedString += specChar[ran - 1];
break;
}
generated_password.Text = GeneratedString;
}
}

private void label3_Click(object sender, EventArgs e)
{
if (generated_password.Text != "")
{
System.Windows.Forms.Clipboard.SetText(generated_password.Text);
alertMessage(1);
}
else
{
alertMessage(2);
}
}

public void alertMessage(int id)
{
switch (id)
{
case 1:
MessageBox.Show("Password Copied To Clipboard", "Information..", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
break;
case 2:
MessageBox.Show("No Content To Copy To Clipboard", "Information..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
break;
case 3:
MessageBox.Show("Please Select a Checkbox", "Information..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
break;
}
}
}
}



Program Download:
You must login or register to view this content.
Source Download:
You must login or register to view this content.



Looks nice although there is another better way to do this. I'm not on my computer with Visual Studio but a little later tonight if I have time I'll show you another way of going about this.

Hint: ASCII conversions. Makes generating lower/upper characters, special characters, numbers very easily.

The following user thanked Pichu for this useful post:

08-09-2014, 12:22 AM #10
Default Avatar
Brad
Guest
Originally posted by Pichu View Post
Looks nice although there is another better way to do this. I'm not on my computer with Visual Studio but a little later tonight if I have time I'll show you another way of going about this.

Hint: ASCII conversions. Makes generating lower/upper characters, special characters, numbers very easily.


Thanks for the feedback! I'm more then happy to see how you'd go around this! Have you got skype?

The following user thanked Brad for this useful post:

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo