Beispiel #1
0
        private void checkconfig()
        {
            MyConfig con = new MyConfig();

            if (con.GetValue("islogin").Equals("False"))
            {
                if (con.GetValue("auto").Equals("false"))
                {
                    if (con.GetValue("savepass").Equals("True"))
                    {
                        user.Text = con.GetValue("username");

                    }
                    return;
                }
                else
                {
                    Main main = new Main();
                    main.Show();
                    this.Close();
                }

            }
        }
Beispiel #2
0
        private void LOGIN_Click(object sender, RoutedEventArgs e)
        {

            if(user.Text == "" || pwd.Text == "" )
            {
                MessageBox.Show(error[1], "Waring", MessageBoxButton.OK,MessageBoxImage.Warning);
            }

            // use MD5 and DES encrypt  user 
            // use SHA and AES encrypt passwd  
            // and check local user if not online check 
            //TODO
            String passwdnum; 
            String usernum = makeuser(user.Text ,pwd.Text);
            MyConfig con = new MyConfig();
            if (con.GetValue("savepass").Equals("True"))
            {
                passwdnum = getPasswdString(usernum); 

            }
            else
            {
              passwdnum = makepwd(pwd.Text);
            }
               
            
            int i = checkall(usernum , passwdnum) ; 
            if(i == 0)
            {
                Eenclass enc =new Eenclass(); 
                byte[] crcword = Encoding.UTF8.GetBytes(passwdnum);
                byte[] crcword2=CRC.crc.CRC16(crcword);
                int times = int.Parse(con.GetValue("querytimes"));
                if (times == 0 )
                {
                    con.SetValue("crc", enc.hex2str(crcword2));
                }
                else
                {
                    byte[] getcrc = enc.str2hex(con.GetValue("crc"));
                    if(!getcrc.Equals(crcword2))
                    {
                        MessageBox.Show("FILE has been modify!!!!"); 
                        return; 
                    } 
                }
                String issave = saveall.IsChecked == true ? "True" : "False";
                con.SetValue("savepass", issave);
                string isauto = checkauto.IsChecked == true ? "True" : "False";
                con.SetValue("auto", isauto);

                Main main = new Main(usernum);
                main.Show();
               
                this.Close(); 
            }
            else if(i ==(int)ERROR.FILE_MISSING)
            {   
                //online check
                MessageBox.Show(error[i], "wrong", MessageBoxButton.OK, MessageBoxImage.Error) ; 
            }
            else if(i == 0xFFBB) 
            {
                return; 
            }
            else
            {
                MessageBox.Show(error[i], "wrong", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            

        }