Last active
June 3, 2016 16:12
-
-
Save Kashkovsky/21474314c39fd0df493a008e92ad4611 to your computer and use it in GitHub Desktop.
Simple password generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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