-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPasswordGen.cs
32 lines (30 loc) · 949 Bytes
/
PasswordGen.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
class PasswordGen{
static void Main(string[] args){
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("<----------Password Generator---------->");
Console.WriteLine("Created by Morasiu ([email protected])");
Console.ReadKey();
Console.WriteLine("Your password:\n" + Generate());
}
static string Generate(){
// A strong password has:
// - at least 15 characters
// - uppercase letters
// - lowercase letters
// - numbers
// - symbols
int length = 15;
string passwd = "";
string lowLetters = "qwertyuiopasdfghjklzxcvbnm";
string upLetters = lowLetters.ToUpper();
string symbols = "[]{}();:!@#$%^&*?=-_+`~";
string numbers = "0123456789";
string all = lowLetters + upLetters + numbers + symbols;
Random rand = new Random();
for(int i = 0; i < length; i++){
passwd += all[rand.Next(0, all.Length)];
}
return passwd;
}
}