C# Simple Password Generator

One of the simplest and easiest approach to generating random passwords, is to use the GetRandomFileName() static method from the Path class.

Snippet below demonstrates this.

   1: using System;

   2: using System.IO;

   3:  

   4: static void Main(string[] args)

   5: {

   6:     // Calls the static method from the Path type

   7:     var randomFolderFile = Path.GetRandomFileName();

   8:  

   9:     // Strips out dot characters

  10:     randomFolderFile = randomFolderFile.Replace(".", ""); 

  11:     Console.WriteLine(randomFolderFile);

  12: }

Happy Coding.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.