Exemplo n.º 1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            string login        = tbLogin.Text;
            string password     = tbPass.Text;
            string confirmation = tbPassConfirmation.Text;

            if (password == confirmation)
            {
                User user = User.Find(string.Format("username = '******'", login));
                if (user == null)
                {
                    SHA256 sha   = SHA256.Create();
                    byte[] bytes = Encoding.ASCII.GetBytes(password);
                    string hash  = Utils.ToHexString(sha.ComputeHash(bytes));
                    DataBase.Query(string.Format(
                                       "INSERT INTO users (priv_level, username, phone_number, password)" +
                                       "VALUES (1, '{0}', '{1}', '{2}');",
                                       login,
                                       mtbPhone.Text,
                                       hash
                                       ));
                    this.Hide();
                    loginForm.Show();
                }
            }
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string login    = tbLogin.Text;
            string password = tbPass.Text;

            SHA256 sha = SHA256.Create();

            byte[] bytes = Encoding.ASCII.GetBytes(password);
            string hash  = Utils.ToHexString(sha.ComputeHash(bytes));

            User user = User.Find(string.Format("username = '******' AND password = '******'", login, hash));

            if (user == null)
            {
            }
            else
            {
                this.Hide();
                MainForm form = new MainForm();
                GlobalState.instance.currentClient = user;
                form.Show();
            }
        }