/// <summary>
        ///   Using the issues the verification system gave this password it is being modified to include required items
        /// </summary>
        /// <param name="idchain"> this is the list of issues that the verification system went through</param>
        /// <param name="pass"> its the password that is being modified</param>
        /// <returns></returns>
        string Recommendation(List <string> idchain, string pass)
        {
            GenerationComponent G = new GenerationComponent(); //we may need to add a certin number of items
            string      temp      = "";                        //temperary stri ng to be added to pass
            List <char> tempstr   = new List <char>();         //list of all items to be added

            foreach (string item in idchain)
            {
                if (item == "spe")
                {
                    tempstr.Add(U.ROS(U.special));
                }
                if (item == "cap")
                {
                    tempstr.Add(U.ROS(U.alpha));
                }
                if (item == "alp")
                {
                    tempstr.Add(U.ROS(U.numbers));
                }
                if (item.All(char.IsDigit)) // if the item is a number it is a requirment of the length
                {
                    /*based in the difference of how many items we have and how many we need we can generate a required items
                     * example password : 12312 needs one cap length of 10 and special charictar so we will
                     * first recieve 12312!D then we will still need 3 items to be generated for us
                     */
                    if (Convert.ToInt32(item) > tempstr.Count)
                    {
                        string x = G.GeneratedPassword(Convert.ToInt32(item) - tempstr.Count);
                        foreach (char c in x)
                        {
                            tempstr.Add(c);
                        }
                    }
                    else if (Convert.ToInt32(item) < tempstr.Count)
                    {
                        string x = G.GeneratedPassword(tempstr.Count - Convert.ToInt32(item));
                        foreach (char c in x)
                        {
                            tempstr.Add(c);
                        }
                    }
                }
            }
            //randomize the objects in the list so recommended passwords are less predictable I dont think this is working
            for (int i = 0; i < tempstr.Count; i++)
            {
                U.Swap(tempstr, i, U.RNG(0, tempstr.Count - 1));
            }
            foreach (char x in tempstr)   //makes everything in the list one string
            {
                temp += x;
            }

            return(pass + temp);
        }
Пример #2
0
        // no code in email yet
        private void Register_Click(object sender, RoutedEventArgs e)
        {
            VerificationComponent VC = new VerificationComponent();
            string m = "";

            if (!VC.IsEmail(EmailBox.Text))
            {
                m = " \n Email in bad format";
            }
            if (VC.Verification(PasswordBox.Text).Contains("Valid") && m == "")
            {
                int result = 0;
                try
                {
                    Conn.ConnectionString = constring;
                    Conn.Open();
                    sql = @"select * from user_table ";
                    cmd = new NpgsqlCommand(sql, Conn);
                    Console.WriteLine(cmd.ExecuteScalar().ToString());
                }
                catch
                {
                    UseWrongLable("database error");
                    Console.WriteLine("database error");
                }
                if (!cmd.ExecuteScalar().ToString().Contains(EmailBox.Text))
                {
                    Conn.Close();
                    EmptyUser = new User(Namebox.Text, EmailBox.Text);
                    GenerationComponent GC = new GenerationComponent();
                    randomcode = GC.GeneratedPassword(15);
                    EmailSystem emailSystem = new EmailSystem(EmptyUser, randomcode);
                    emailSystem.Email();
                    Register.Visibility         = Visibility.Hidden;
                    CodeVerification.Visibility = Visibility.Visible;
                    Wrong.Visibility            = Visibility.Hidden;
                }
                else
                {
                    Conn.Close();
                    UseWrongLable("that email is already registered");
                }
            }
            else
            {
                UseWrongLable(VC.Verification(PasswordBox.Text) + m);
            }
        }
Пример #3
0
        private void Refresh_Click(object sender, RoutedEventArgs e)
        {
            GenerationComponent   GC = new GenerationComponent();
            VerificationComponent VC = new VerificationComponent();
            string newpass           = GC.GeneratedPassword(GC.U.RNG(10, 13));

            if (VC.Verification(newpass).Contains("Valid"))
            {
                PasswordGen.Text = newpass;
            }
            else
            {
                PasswordGen.Text = GC.GeneratedPassword(GC.U.RNG(10, 13));
            }
            Console.WriteLine(PasswordGen.Text);
        }
Пример #4
0
        public MainWindow(User user)
        {
            CurrentUser = user;
            Console.WriteLine(CurrentUser.Email);
            InitializeComponent();
            Console.WriteLine("We're  in");
            GenerationComponent GC = new GenerationComponent();
            Utilitys            U  = new Utilitys();

            PasswordGen.Text = GC.GeneratedPassword(U.RNG(10, 13));
            NpgsqlConnection Conn = new NpgsqlConnection();

            NameLable.Content     = CurrentUser.Name + "\n" + CurrentUser.Email;
            Conn.ConnectionString = LoginSystem.constring;
            Conn.Open();
            try
            {
                NpgsqlCommand command = new NpgsqlCommand(string.Format("SELECT companyname,passoword FROM passvault WHERE useremail=\'{0}\';", CurrentUser.Email), Conn);
                Console.WriteLine();
                NpgsqlDataAdapter da = new NpgsqlDataAdapter(command);
                DataTable         dt = new DataTable();
                da.Fill(dt);

                List <string> websites  = new List <string>();
                List <string> passwords = new List <string>();
                foreach (DataRow row in dt.Rows)
                {
                    websites.Add(row.Field <string>(0));
                    passwords.Add(row.Field <string>(1));
                }

                for (int i = 0; i < passwords.Count; i++)
                {
                    Console.WriteLine("{0} {1}", websites[i], passwords[i]);
                    Viewer.Items.Add(websites[i] + " " + passwords[i]);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("assumed passvault empty" + e.Message);
                usewronglable("WELCOME :)");
            }
            Conn.Close();
        }