Esempio n. 1
0
 private void delete_Click(object sender, RoutedEventArgs e)
 {
     int i = 0;  
     if (COMBOBOX.SelectedItem != null)
     {
         Eenclass enc = new Eenclass();
         string delete = COMBOBOX.Text; 
         COMBOBOX.Items.Remove(COMBOBOX.SelectedItem);
         i = deletexml(delete);
         queryfinal(i) ;
     }
 }
Esempio n. 2
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 = "";

        }
Esempio n. 3
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 = ""  ; 
        }
Esempio n. 4
0
        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; 
            
        }
Esempio n. 5
0
        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; 
        }
Esempio n. 6
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);
            }
            

        }
Esempio n. 7
0
        public bool encrypt(string user ,string passwd)
        {

            byte[] userbyte = System.Text.Encoding.UTF8.GetBytes(user);
            byte[] pass = System.Text.Encoding.UTF8.GetBytes(passwd);
            Eenclass enc; 
            bool isexist = true ; 
            
            enc = new Eenclass(userbyte) ;
            byte[] md5user = enc.Mymd5() ; //202cb962
            enc = new Eenclass(pass); 
            byte[] shapass = enc.MySHA256() ;
            enc = new Eenclass(md5user, pass); //a665a459 
            byte[] final_user = enc.desenc();
            enc = new Eenclass(shapass, pass); // 1eaf67e9 
            byte[] final_pass = enc.aesenc(); //d63804

            isexist = send2server(final_user);
           
            if (isexist == true)
                return isexist; 
            
            createXml(final_user, final_pass);
           
            return isexist;


        }