private void btnHiddenSave_Click(object sender, RoutedEventArgs e) { HashEncrypt he = new HashEncrypt(true, false); if (BLL.TB_Setting.OldPwd == "") { if (txtHiddenNewPwd.Password == "") { MessageBox.Show("请输入新密码!"); return; } if (txtHiddenReNewPwd.Password == "") { MessageBox.Show("请输入确认新密码!"); return; } if (txtHiddenNewPwd.Password.Trim() != txtHiddenReNewPwd.Password.Trim()) { MessageBox.Show("新密码和确认新密码输入不一致,\r\n请重新输入!"); return; } } else { if (txtHiddenOldPwd.Password == "") { MessageBox.Show("请输入原始密码!"); return; } if (txtHiddenNewPwd.Password == "") { MessageBox.Show("请输入新密码!"); return; } if (txtHiddenReNewPwd.Password == "") { MessageBox.Show("请输入确认新密码!"); return; } if (txtHiddenNewPwd.Password.Trim() != txtHiddenReNewPwd.Password.Trim()) { MessageBox.Show("新密码和确认新密码输入不一致,\r\n请重新输入!"); return; } if (he.SHA1Encrypt(txtHiddenOldPwd.Password.Trim()) != BLL.TB_Setting.OldPwd) { MessageBox.Show("原始密码输入错误!", "系统信息"); return; } } BLL.TB_Setting.UpdatePwd(he.SHA1Encrypt(txtHiddenNewPwd.Password.Trim())); txtHiddenOldPwd.Password = ""; txtHiddenNewPwd.Password = ""; txtHiddenReNewPwd.Password = ""; MessageBox.Show("密码设置成功!"); }
private void btnHiddenSave_Click(object sender, RoutedEventArgs e) { HashEncrypt he = new HashEncrypt(true, false); if (BLL.TB_Setting.OldPwd == "") { if (txtHiddenNewPwd.Password == "") { MessageBox.Show("请输入新密码!"); return; } if (txtHiddenReNewPwd.Password == "") { MessageBox.Show("请输入确认新密码!"); return; } if (txtHiddenNewPwd.Password.Trim() != txtHiddenReNewPwd.Password.Trim()) { MessageBox.Show("新密码和确认新密码输入不一致,\r\n请重新输入!"); return; } } else { if (txtHiddenOldPwd.Password == "") { MessageBox.Show("请输入原始密码!"); return; } if (txtHiddenNewPwd.Password == "") { MessageBox.Show("请输入新密码!"); return; } if (txtHiddenReNewPwd.Password == "") { MessageBox.Show("请输入确认新密码!"); return; } if (txtHiddenNewPwd.Password.Trim() != txtHiddenReNewPwd.Password.Trim()) { MessageBox.Show("新密码和确认新密码输入不一致,\r\n请重新输入!"); return; } if (he.SHA1Encrypt(txtHiddenOldPwd.Password.Trim()) != BLL.TB_Setting.OldPwd) { MessageBox.Show("原始密码输入错误!", "系统信息"); return; } } BLL.TB_Setting.UpdatePwd(he.SHA1Encrypt(txtHiddenNewPwd.Password.Trim())); txtHiddenOldPwd.Password = ""; txtHiddenNewPwd.Password = ""; txtHiddenReNewPwd.Password = ""; MessageBox.Show("密码设置成功!"); }
private void btnSave_Click(object sender, RoutedEventArgs e) { HashEncrypt he = new HashEncrypt(true, false); BLL.TB_Setting.UpdatePwd(he.SHA1Encrypt(txtPwd.Password.Trim())); this.DialogResult = true; this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { HashEncrypt he = new HashEncrypt(true, false); BLL.TB_Setting.UpdatePwd(he.SHA1Encrypt(txtPwd.Password.Trim())); this.DialogResult = true; this.Close(); }
public T DecryptCookie <T>(string cookieValue, Dictionary <string, string> parameters) { T result = default(T); string strEncCookieValue = string.Empty; string strContent = string.Empty; string strSHA1Sign = string.Empty; string strShA1Temp = string.Empty; string[] arrayCookieValue = new string[2]; try { if (cookieValue.Length < 40) { return(result); } // 取出签名和密文 strSHA1Sign = cookieValue.Substring(0, 40); strEncCookieValue = cookieValue.Substring(40); // 签名校验 strShA1Temp = HashEncrypt.SHA1Encrypt(HttpUtility.UrlDecode(strEncCookieValue).Trim() + parameters["hashkey"]); if (strSHA1Sign != strShA1Temp) { return(result); } strEncCookieValue = HttpUtility.UrlDecode(strEncCookieValue); // 还原成明文 strContent = RC4Encrypt.Decrypt(strEncCookieValue, parameters["rc4key"], RC4Encrypt.EncoderMode.HexEncoder); if (strContent.Length == 0) { return(result); } arrayCookieValue = JsonConvert.DeserializeObject <string[]>(strContent); if (arrayCookieValue != null && arrayCookieValue.Length == 3) { if (DateTime.Parse(arrayCookieValue[1]) > DateTime.Now && GetClientIP() == arrayCookieValue[2]) { result = JsonConvert.DeserializeObject <T>(arrayCookieValue[0]); //Cookie有效,则继续延续有效期 IocManager.Instance.IocContainer.Resolve <CookieHelper>().SaveCookie <T>(parameters["nodeName"], result); //CookieHelper.SaveCookie<T>(parameters["nodeName"], result); } } return(result); } catch { return(result); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (he.SHA1Encrypt(txtPwd.Password.Trim()) == BLL.TB_Setting.OldPwd) { this.DialogResult = true; this.Close(); } else { MessageBox.Show("密码输入错误!", "系统信息"); txtPwd.Password = ""; } }
public string EncryptCookie <T>(T obj, Dictionary <string, string> parameters) { string strCookieValue = string.Empty; string strEncCookieValue = string.Empty; string strSHA1Sign = string.Empty; strCookieValue = SerializationUtility.JsonSerialize3(obj); strEncCookieValue = RC4Encrypt.Encrypt(strCookieValue, parameters["rc4key"], RC4Encrypt.EncoderMode.HexEncoder).Trim(); strSHA1Sign = HashEncrypt.SHA1Encrypt(strEncCookieValue + parameters["hashkey"]); strEncCookieValue = HttpUtility.UrlEncode(strEncCookieValue); strEncCookieValue = strSHA1Sign + strEncCookieValue; return(strEncCookieValue); }
public T DecryptCookie <T>(string cookieValue, Dictionary <string, string> parameters) { T result = default(T); string strEncCookieValue = string.Empty; string strContent = string.Empty; string strSHA1Sign = string.Empty; string strShA1Temp = string.Empty; try { if (cookieValue.Length < 40) { return(result); } // 取出签名和密文 strSHA1Sign = cookieValue.Substring(0, 40); strEncCookieValue = cookieValue.Substring(40); // 签名校验 strShA1Temp = HashEncrypt.SHA1Encrypt(HttpUtility.UrlDecode(strEncCookieValue).Trim() + parameters["hashkey"]); if (strSHA1Sign != strShA1Temp) { return(result); } strEncCookieValue = HttpUtility.UrlDecode(strEncCookieValue); // 还原成明文 strContent = RC4Encrypt.Decrypt(strEncCookieValue, parameters["rc4key"], RC4Encrypt.EncoderMode.HexEncoder); if (strContent.Length == 0) { return(result); } result = SerializationUtility.JsonDeserialize3 <T>(strContent); return(result); } catch { return(result); } }
public string EncryptCookie <T>(T obj, Dictionary <string, string> parameters) { string strCookieValue = string.Empty; string strEncCookieValue = string.Empty; string strSHA1Sign = string.Empty; string[] arrayCookieValue = new string[3]; int securityExpires = 0; int.TryParse(parameters["securityExpires"], out securityExpires); arrayCookieValue[0] = JsonConvert.SerializeObject(obj); arrayCookieValue[1] = DateTime.Now.AddMinutes(securityExpires).ToString(); arrayCookieValue[2] = GetClientIP(); strCookieValue = JsonConvert.SerializeObject(arrayCookieValue); strEncCookieValue = RC4Encrypt.Encrypt(strCookieValue, parameters["rc4key"], RC4Encrypt.EncoderMode.HexEncoder).Trim(); strSHA1Sign = HashEncrypt.SHA1Encrypt(strEncCookieValue + parameters["hashkey"]); strEncCookieValue = HttpUtility.UrlEncode(strEncCookieValue); strEncCookieValue = strSHA1Sign + strEncCookieValue; return(strEncCookieValue); }
private string SHA1Sign(string strInput) { return(_objHash.SHA1Encrypt(strInput + X_SIGN_KEY_S2)); }