Random Password Generator On C# Including Numbers And Letters

in #utopian-io8 years ago (edited)

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++;

1.png

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++;

2.png

Now i am equalizing my new array to zero and making "pass" in string type.


Console.WriteLine();

        string Pass = ""; 
        int Array = 0;

After doing that i am using "random" variable to generate random character or number then making it have maximum 35 characters.


Random Generate = new Random();
for (i = 0; i <= 9; i++)
Array = Generate.Next(0, 35);

3.png

On the final step i am equalizing "pass" to my array and making console to write my new generated password.


Pass = Pass + Char[Array];
Console.WriteLine("New Password Is = " + Pass);
Console.ReadKey();

4.png

Output The Of Program

5.png



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

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]

Coin Marketplace

STEEM 0.12
TRX 0.34
JST 0.033
BTC 113030.30
ETH 4195.72
USDT 1.00
SBD 0.87