Exemple #1
0
        private void UpDate_Click(object sender, RoutedEventArgs e)
        {
            if (!File.Exists("message.xml"))
            {
                MessageBox.Show("FILE MISSING"); 
            }
            if ( COUNT.Text == "" || KEY.Text == "" || SEC.Text == "")
            {
                MessageBox.Show(myerror[0], "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else
            {
                string showmessage = String.Format(show[0], COMBOBOX.Text, COUNT.Text, KEY.Text, SEC.Text);
                if (MessageBox.Show(showmessage, "IMPORTANT", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    COUNT.Text = "";
                    KEY.Text = "";
                    SEC.Text = "";
                    return;
                }
            }

            byte[] user = Encoding.UTF8.GetBytes(COUNT.Text);
            byte[] pass = Encoding.UTF8.GetBytes(KEY.Text);

            byte[] sec = Encoding.UTF8.GetBytes(SEC.Text);
            Eenclass enc = new Eenclass();

            string rsauser = enc.hex2str(enc.aesenc(user, sec));
            string rsapass = enc.hex2str(enc.aesenc(pass, sec));

            send2serverall(username, COMBOBOX.Text, rsauser, rsapass);
            save2xml(username, TAG.Text, rsauser, rsapass,UPDATE);

            COUNT.Text = "";
            SEC.Text = "";
            KEY.Text = "";
            TAG.Text = "";

        }
Exemple #2
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            if(TAG.Text=="" || COUNT.Text=="" || KEY.Text=="" ||SEC.Text =="")
            {
                MessageBox.Show(myerror[0] , "ERROR" , MessageBoxButton.OK ,MessageBoxImage.Error) ;
                return ; 
            }
            else
            {
                 string showmessage = String.Format(show[0] , TAG.Text , COUNT.Text  ,KEY.Text ,SEC.Text) ; 
                if( MessageBox.Show(showmessage, "IMPORTANT", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    COUNT.Text = "" ;
                    KEY.Text = ""  ;
                    SEC.Text =""   ; 
                    return; 
                }
            }

            COMBOBOX.Items.Add(TAG.Text) ; 
            
            // first use DES .....
            byte[] user = Encoding.UTF8.GetBytes(COUNT.Text) ; 
            byte[] pass = Encoding.UTF8.GetBytes(KEY.Text)   ;
           
            byte[] sec = Encoding.UTF8.GetBytes(SEC.Text)    ;
            Eenclass enc = new Eenclass() ;
            string rsauser = enc.hex2str(enc.aesenc(user, sec)) ; 
            string rsapass = enc.hex2str(enc.aesenc(pass, sec)) ;
        
            
            send2serverall(username ,TAG.Text ,rsauser , rsapass ) ;
            save2xml(username,TAG.Text,rsauser,rsapass,ADD);

            COUNT.Text = "";
            SEC.Text = ""  ;
            KEY.Text = ""  ;
            TAG.Text = ""  ; 
        }
        private string makepwd(string passwd)
        {
            Eenclass enc; 
            byte[] pass = Encoding.UTF8.GetBytes(passwd) ;
            enc = new Eenclass(pass);
            byte[] shapass = enc.MySHA256(); 
            enc = new Eenclass(shapass, pass);
            byte[] aaa = enc.aesenc();
            string result = enc.hex2str(aaa);

            return result; 
        }
        private string makeuser(string user,string passwd )
        {
            Eenclass enc; 
            byte[] users = Encoding.UTF8.GetBytes(user); 
            byte[] pass = Encoding.UTF8.GetBytes(passwd);
            enc = new Eenclass(users);
            byte[] md5user = enc.Mymd5();
            enc = new Eenclass(md5user, pass);  
            byte[] aaa = enc.desenc();
            string result = enc.hex2str(aaa);

            return result; 
            
        }
        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);
            }
            

        }