Random Password Generator On C# Including Numbers And Letters
What Will I Learn?
- You will learn how to use c# for generating new password
- You will learn how to use arrays on c#
Requirements
- Basic knowledge of coding
- Basic knowledge of c#
Difficulty
- Basic
Tutorial Contents
Hello,in this tutorial i am going to show you how to make a program that generates random password on c#.
I am defining libraries and naming my program.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Password_Generator
class Program
static void Main(string[] args)
Now this part is important,i am creating a new array here and making that array have 36 characters.
char[] Char = new char[36];
int i = 0;
Now generating numbers on characters with using "for" loop.
for (char k = 'a'; k <= 'z'; k++)
Char[i] = k;
i++;
After that i am doing same job on numbers this time.This line will generate numbers in password.
for (char k = '0'; k <= '9'; k++)
Char[i] = k;
i++;
Now i am equalizing my new array to zero and making "pass" in string type.
After doing that i am using "random" variable to generate random character or number then making it have maximum 35 characters. On the final step i am equalizing "pass" to my array and making console to write my new generated password.
Console.WriteLine();
string Pass = "";
int Array = 0;
Random Generate = new Random();
for (i = 0; i <= 9; i++)
Array = Generate.Next(0, 35);
Pass = Pass + Char[Array];
Console.WriteLine("New Password Is = " + Pass);
Console.ReadKey();
Output The Of Program
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it is not as informative as other contributions. See the Utopian Rules. Contributions need to be informative and descriptive in order to help readers and developers understand them.
You can contact us on Discord.
[utopian-moderator]