private void Button_Click(object sender, RoutedEventArgs e) { if (LoginCombo.SelectedIndex >= 0) { string frontserver = AddressCollection[LoginCombo.SelectedIndex]; string brokerId = userBroker.Text; string uid = userTxt.Text; string password = passwordTxt.Password; if (SignInManager.SignInOptions.FrontServer != frontserver || SignInManager.SignInOptions.BrokerID != brokerId || SignInManager.SignInOptions.UserName != uid || SignInManager.SignInOptions.Password != password) { SignInManager.SignInOptions.FrontServer = frontserver; SignInManager.SignInOptions.BrokerID = brokerId; SignInManager.SignInOptions.UserName = uid; if (SignInManager.SignInOptions.EncryptPassword) { _hashEncoder.Option.Iteration = MD5Round; password = _hashEncoder.Encode(password); } SignInManager.SignInOptions.Password = password; } SignInManager.SignIn(); loginBtn.IsEnabled = false; } }
private void Button_Click(object sender, RoutedEventArgs e) { uint round = (uint)(roundComboBox.SelectedIndex + 1); if (round > 0) { _hashEncoder.Option.Iteration = round; md5TextBox.Text = _hashEncoder.Encode(md5TextBox.Text); } }
public void EncodeAndDecodeNullHash() { HashEncoder encoder = new HashEncoder(); byte[] bytes = encoder.Encode(null); Assert.IsNotNull(bytes); Assert.AreNotEqual(0, bytes.Length); Hash result = encoder.Decode(bytes); Assert.IsNull(result); }
public Task <bool> ResetPassword(string newPassword, int timeout = 10000) { if (string.IsNullOrEmpty(newPassword)) { return(Task.FromResult(false)); } var msgId = (uint)AccountManageMessageID.MSG_ID_RESET_PASSWORD; var tcs = new TaskCompletionSource <bool>(new CancellationTokenSource(timeout)); var serialId = NextSerialId; var sst = new StringMap(); sst.Header = new DataHeader { SerialId = serialId }; _hashEncoder.Option.Iteration = MD5Round; sst.Entry[FieldName.PASSWORD] = _hashEncoder.Encode(newPassword); #region callback MessageWrapper.RegisterAction <Result, ExceptionMessage> (msgId, (resp) => { if (resp?.SerialId == serialId) { tcs.TrySetResult(true); } }, (ExceptionMessage bizErr) => { tcs.SetResult(false); } ); #endregion MessageWrapper.SendMessage(msgId, sst); return(tcs.Task); }
//private IEnumerable<PortfolioVM> SeletedQuoteVM //{ // get // { // var selectedItems = portofolioTextBox.SelectedText; // } //} private async void Button_Click_Reset(object sender, RoutedEventArgs e) { string password = originalPasswordTextBox.Password; if (password != null) { _hashEncoder.Option.Iteration = MD5Round; password = _hashEncoder.Encode(password); } if (Password == password) { if (resetPasswordTextBox.Password == "") { this.resetPasswordTextBox.Background = new SolidColorBrush(Colors.Red); MessageBox.Show(this, "输入不能为空"); this.resetPasswordTextBox.Background = new SolidColorBrush(Colors.White); return; } else if (resetPasswordTextBox.Password != affirmPasswordTextBox.Password) { MessageBox.Show(this, "两次密码输入不一致,请重新输入!", "系统提示"); return; } else if (resetPasswordTextBox.Password == affirmPasswordTextBox.Password) { bool bSuc = await MessageHandlerContainer.DefaultInstance.Get <AccountHandler>().ResetPassword(resetPasswordTextBox.Password); if (!bSuc) { MessageBox.Show(this, "修改密码失败!", "系统提示"); } else { MessageBox.Show(this, "密码修改成功!请重启程序", "系统提示"); } this.Close(); } } else { MessageBox.Show(this, "原密码错误!", "系统提示"); } }