public async Task <IActionResult> AddUser(string email, string state) { var policyNumber = GenerateRandomAlphanumeric.GenerateRandomAlphanumericString(5); var user = new IdentityUser { UserName = policyNumber, Email = email, }; var pwdGen1 = new PasswordGenerator.Password(); string password1 = pwdGen1.Next(); var result = await _userManager.CreateAsync(user, password1); if (result.Succeeded) { return(Json(user.UserName)); } else { var emailExist = "emailExist"; return(Json(emailExist)); } }
static void Main(string[] args) { Console.WriteLine("start"); Console.WriteLine("How many passwords needed:"); var input = Console.ReadLine(); int amount = 0; int length = 0; bool convertResult = Int32.TryParse(input, out amount); if (convertResult == false) { Console.WriteLine("Input not a number! Exit"); Environment.Exit(1); } Console.WriteLine("Lenght of password:"******"Input not a number! Exit"); Environment.Exit(1); } PasswordGenerator.Password gen = new PasswordGenerator.Password(); gen.Settings = new PasswordGenerator.PasswordSettingsReadable(false, true, true, false, length, 10, false); List <string> bulkList = new List <string>(); Console.WriteLine("generate: "); int n = 0; while (n < amount) { string singlePassword = gen.Next(); if (bulkList.Contains(singlePassword)) { Console.WriteLine("error"); continue; } else { Console.Write("found a new one: "); bulkList.Add(singlePassword); n++; Console.WriteLine(n); } } Console.WriteLine("OK"); Console.WriteLine("Write to file: "); // to file string currentDir = Environment.CurrentDirectory; System.IO.File.WriteAllLines( System.IO.Path.Combine(currentDir, "output.txt"), bulkList); Console.WriteLine("OK"); Console.WriteLine("Finish"); Console.ReadLine(); }
public PasswordHelper() { var pwd = new PasswordGenerator.Password().IncludeLowercase().IncludeUppercase().IncludeSpecial().LengthRequired(8); Password = pwd.Next(); }