示例#1
0
        private void SignInButton_Click(object sender, RoutedEventArgs e)
        {
            Database1Timerstuff ts = new Database1Timerstuff();

            Database1TimerstuffTableAdapters.UserInfoTableAdapter ad = new Database1TimerstuffTableAdapters.UserInfoTableAdapter();
            ad.Connection = new System.Data.SqlServerCe.SqlCeConnection("Data Source=\"C:\\Users\\Thad\\Documents\\Programming Practice\\Productivity Timer\\Productivity Timer\\Database1.sdf\"");

            ad.Fill(ts.UserInfo);

            HashAlgorithm alg = MD5.Create();

            alg.ComputeHash(Encoding.UTF8.GetBytes(PasswordBox.Text));

            byte[] pw = ad.GetPassword(UserNameBox.Text);

            byte[] pwHash = alg.Hash;



            if (pw.SequenceEqual(pwHash))
            {
                Username = UserNameBox.Text;

                this.DialogResult = true;
                this.Close();
            }
        }