Ejemplo n.º 1
0
        public IActionResult Generate([FromBody] PasswordGenModel body)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            List <string> pwds = new List <string>();

            PasswordGen pwdGen = new PasswordGen()
            {
                Exclusions            = Convert.ToString(body.Exclusions),
                Maximum               = Convert.ToInt32(body.Maximum),
                ConsecutiveCharacters = Convert.ToBoolean(body.ConsecutiveCharacters),
                RepeatCharacters      = Convert.ToBoolean(body.RepeatCharacters),
                ExcludeSymbols        = Convert.ToBoolean(body.ExcludeSymbols)
            };

            for (int i = 0; i < 10; i++)
            {
                string pwd = pwdGen.Generate();
                pwds.Add(pwd);
            }

            return(Ok(pwds));
        }
Ejemplo n.º 2
0
 public IActionResult Index()
 {
     ViewBag.Password = new PasswordGen().GetPassword(14);
     System.Console.WriteLine(ViewBag.Password);
     ViewBag.Count = PasswordGen.GetCount();
     return(View());
 }
        private List <string> sugPass(PasswordGen pass)
        {
            string Name  = pass.LastName;
            string Year  = pass.BirthYear;
            string Color = pass.FavColor;

            //builds new instance of the string builder called passbuilder and sets the maximum capacity of the string to 8
            StringBuilder passBuilder = new StringBuilder();

            passBuilder.Capacity = 8;

            //builds password with lastname and color
            passBuilder.Append(Name);
            passBuilder.Append(Color);
            string pass1 = passBuilder.ToString();

            //builds password with color and year
            passBuilder.Remove(0, 8);
            passBuilder.Append(Color);
            passBuilder.Append(Year);
            string pass2 = passBuilder.ToString();

            //password with lastname and color inserted at the fourth letter
            passBuilder.Remove(0, 8);
            passBuilder.Append(Name);
            passBuilder.Insert(4, Color);
            string pass3 = passBuilder.ToString();

            //builds password with year and name
            passBuilder.Remove(0, 8);
            passBuilder.Append(Year);
            passBuilder.Append(Name);
            string pass4 = passBuilder.ToString();

            //builds password with the year, the name inserted at the third character, and the color at the sixth character
            passBuilder.Remove(0, 8);
            passBuilder.Append(Year);
            passBuilder.Insert(2, Name);
            passBuilder.Insert(6, Color);
            string pass5 = passBuilder.ToString();

            //creates a list of the passwords generated, sorts the passwords and then sets that variable ist as the datasource of the passDD and then binds that data to the passDD
            var passwords = new List <string> {
                pass1, pass2, pass3, pass4, pass5
            };

            return(passwords);
        }
        public ActionResult PasswordGenerator(PasswordGen user)
        {
            if (user.SelectedPassword != "Suggest A Password")
            {
                var Current = GetTempUser();

                Current.Password = user.SelectedPassword;
                db.Users.Add(Current);
                db.SaveChanges();
                return(View("Login"));
            }

            //Insert Code here that generates a list and displays it in the PasswordGenerator View
            List <string> passwordList = new List <string>();

            passwordList = sugPass(user);



            ViewBag.PasswordOptions = passwordList;
            return(View());
        }
Ejemplo n.º 5
0
 // GET: /<controller>/
 public IActionResult Index()
 {
     ViewBag.Password = new PasswordGen().GetPassword(14);
     ViewBag.Count    = PasswordGen.GetCount();
     return(View());
 }