Skip to content

Instantly share code, notes, and snippets.

@Kashkovsky
Last active June 3, 2016 16:12
Show Gist options
  • Save Kashkovsky/21474314c39fd0df493a008e92ad4611 to your computer and use it in GitHub Desktop.
Save Kashkovsky/21474314c39fd0df493a008e92ad4611 to your computer and use it in GitHub Desktop.
Simple password generator
using System;
using System.Text;
namespace Common.Utility
{
public class PasswordGenerator
{
public static string Create(int length = 8)
{
const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
var res = new StringBuilder();
var rnd = new Random();
while (0 < length--)
{
res.Append(valid[rnd.Next(valid.Length)]);
}
return res.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment