Created
September 13, 2016 10:46
-
-
Save henrikse55/cbf1156f04b42314e859ca57a479402d to your computer and use it in GitHub Desktop.
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
public Dictionary<int, string> GenerateKey(Case c, int amount, int length) | |
{ | |
if (rand == null) rand = new Random(); | |
if (Keys.Count() > 0) Keys.Clear(); | |
//Run the amount of keys | |
for (int a = 0; a < amount; a++) { | |
//Generate Chars here | |
for (int l = 0; l < length; l++){ | |
Boolean isNumber = rand.Next(0, 50) <= 30; | |
Boolean IsUpper = rand.Next(0, 50) <= 30; | |
builder.Append((isNumber ? Numbers.ElementAt(rand.Next(0, Numbers.Length)) : c == Case.both ? (IsUpper ? char.ToUpper(Charaters.ElementAt(rand.Next(0, Charaters.Length))) : Charaters.ElementAt(rand.Next(0, Charaters.Length))) : c == Case.upper ? char.ToUpper(Charaters.ElementAt(rand.Next(0, Charaters.Length))) : char.ToLower(Charaters.ElementAt(rand.Next(0, Charaters.Length))))); | |
} | |
Keys.Add(a, builder.ToString()); | |
builder.Clear(); | |
} | |
return Keys; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment