private void Ok_Click(object sender, EventArgs e)
        {
            if (this.textBoxPass.Text.Length < 8)
            {
                MessageBox.Show("Password must be at least 8 characters.", "Password too short!");
                DialogResult = DialogResult.None;
            }
            else if (!string.IsNullOrEmpty(this.textBoxPass.Text) && this.textBoxPass.Text == this.textBoxPassConfirmed.Text)
            {
                var createdPw = PasswordInformation.Create(this.passwordFilePath, this.textBoxPass.Text, Convert.ToUInt32(this.numericUpDown1.Value));

                MessageBox.Show("Password successfully created!", "Success");

                this.authenticationResult.EnteredPasswordAsString = this.textBoxPass.Text;
                this.authenticationResult.PasswordSalt            = createdPw.PasswordSalt;
                this.authenticationResult.Success = true;

                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Please enter and confirm a valid password!", "Confirm");
                DialogResult = DialogResult.None;
            }
        }
Пример #2
0
        public void TestHashRenew()
        {
            using (var tmp = TempDir.Create())
            {
                var file = Path.Combine(tmp.Name, "key.xml");

                var created = PasswordInformation.Create(file, pass, hashIterations);

                created.RenewHash(pass);
                created.Save(file);

                var loaded = PasswordInformation.Load(file);
                Assert.IsTrue(loaded.PasswordIsCorrect(pass));
                Assert.IsTrue(loaded.PasswordSalt.SequenceEqual(created.PasswordSalt));
            }
        }