Example #1
0
 /// <summary>生パスワードと塩味パスワードを比較認証</summary>
 private void btnSPWDAuth_Click(object sender, EventArgs e)
 {
     if (GetHash.EqualSaltedPasswd(
             this.txtSPWDRawPassword.Text, this.txtSPWDSaltedPassword.Text,
             (EnumHashAlgorithm)this.cbxSPWDPV.SelectedValue, (int)this.nudSPWDSaltLength.Value))
     {
         MessageBox.Show("認証成功");
     }
     else
     {
         MessageBox.Show("認証失敗");
     }
 }
Example #2
0
        public void GetSaltedPasswdTest(string rawPwd, EnumHashAlgorithm eha, int saltLength)
        {
            try
            {
                // Get the Salt password using the components of touryo.
                string saltedPasswd = GetHash.GetSaltedPasswd(rawPwd, eha, saltLength);

                // Check salt password to see if they match.
                Assert.IsTrue(GetHash.EqualSaltedPasswd(rawPwd, saltedPasswd, eha, saltLength));

                // (Just in case) Salt length is different, make sure that the salt passwords do not match.
                Assert.IsFalse(GetHash.EqualSaltedPasswd(rawPwd, saltedPasswd, eha, saltLength + 1));
            }
            catch (Exception ex)
            {
                // Print a stack trace when an exception occurs.
                Console.WriteLine(ex.StackTrace);
                throw;
            }
        }