protected void btnOK_OnClick(object sender, EventArgs e) { if (YeAdministrator.Password != DESUtil.Encrypt(tbxOldPwd.Text)) { WebUtil.Alert("您输入的当期登录密码不正确!"); tbxOldPwd.Focus(); } else { var newPwd = DESUtil.Encrypt(tbxNewPwd1.Text.Trim()); if (AdministratorBll.ChangePassword(YeAdministratorId, newPwd)) { AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = YeAdministratorId, LogTypeName = LogType.修改密码.ToString(), CreateTime = DateTime.Now }); WebUtil.Alert("密码修改成功!"); YeAdministrator.Password = newPwd; } else { WebUtil.Alert("密码修改失败!"); } } }
protected void btnLogin_OnClick(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbxAccount.Text)) { WebUtil.Alert("用户名不能为空!"); return; } if (string.IsNullOrWhiteSpace(tbxPassword.Text)) { WebUtil.Alert("密码不能为空!"); return; } var admin = AdministratorBll.Login(tbxAccount.Text.Trim(), DESUtil.Encrypt(tbxPassword.Text)); if (admin != null) { AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = admin.AdministratorID, LogTypeName = LogType.登录系统.ToString(), CreateTime = DateTime.Now }); Session["YeAdministratorId"] = admin.AdministratorID; Cache["YeAdministrator"] = admin; Response.Redirect("~/YellEatAdmin/Default.aspx", true); } else { WebUtil.AlertAndRedirect("用户名或密码不正确!", "Login.aspx"); } }
static SysConfig() { var file = HttpContext.Current.Server.MapPath("/System.config.xml"); if (!File.Exists(file)) { using (var fs = File.Create(file)) { _systemConfig = new SysConfig(); _systemConfig.EmailPassword = "******"; _systemConfig.Email = "*****@*****.**"; _systemConfig.EmailAccount = "yelleat"; _systemConfig.EmailHost = "smtp.exmail.qq.com"; var serializer = new XmlSerializer(typeof(SysConfig)); var writer = new StreamWriter(fs); serializer.Serialize(writer, _systemConfig); writer.Close(); } } else { var xml = new XmlSerializer(typeof(SysConfig)); _systemConfig = (SysConfig)xml.Deserialize(new FileStream(file, FileMode.OpenOrCreate)); _systemConfig._password = DESUtil.Decrypt(_systemConfig._password); } }
//private static string file = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"DBConn.config"; public static string GetConnectionString(string key) { String connstr = GetAttributeValue("//connectionStrings", key, "connectionString"); connstr = DESUtil.DecryptString(connstr, DESUtil.GenerateKey()); return(connstr); }
protected void btnLogin_OnClick(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbxAccount.Text)) { WebUtil.Alert("用户名不能为空!"); return; } if (string.IsNullOrWhiteSpace(tbxPassword.Text)) { WebUtil.Alert("密码不能为空!"); return; } var shop = ShopBll.Login(tbxAccount.Text.Trim(), DESUtil.Encrypt(tbxPassword.Text)); if (shop != null) { Session["YeShopId"] = shop.ShopID; Cache["Ye_Shop"] = shop; Response.Redirect("Default.aspx", true); } else { WebUtil.AlertAndRedirect("用户名或密码不正确!", "Login.aspx"); } }
protected void btnSendEmail_OnClick(object sender, EventArgs e) { try { var user = UserBll.GetPasswordByEmail(tbxEmail.Text.Trim()); if (user == null) { WebUtil.Alert("Email doesn't exist."); return; } var host = SysConfig.Instance.EmailHost; var emailPassword = DESUtil.Decrypt(SysConfig.Instance.EmailPassword); var email = SysConfig.Instance.Email; var client = new SmtpClient(host); client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(email, emailPassword); client.DeliveryMethod = SmtpDeliveryMethod.Network; var addressFrom = new MailAddress(email, ""); var addressTo = new MailAddress(tbxEmail.Text.Trim(), "Get Password"); var message = new MailMessage(addressFrom, addressTo); message.Subject = "Get Password"; message.Body = "Dear Sir or Madam,it's from Yelleat.Your password is '" + DESUtil.Decrypt(user.Password) + "' .Keep it please."; message.Sender = new MailAddress(email); message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; client.Send(message); WebUtil.Alert("Email is sent Successfully."); } catch { WebUtil.Alert("Email is sent failed", this.Page); } }
/// <summary> /// 登录页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnLogin_OnClick(object sender, EventArgs e) { var user = UserBll.Login(tbxUserName.Text.Trim(), DESUtil.Encrypt(tbxPwd.Text.Trim())); if (user == null) { WebUtil.Alert("Email,mobile or password is incorrect!"); } else { UserBll.UpdateUserLastLoginTime(user.UserID); if (Request.Cookies["location"] == null) { var cookie = new HttpCookie("location", user.Address); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies["location"].Value = user.Address; } if (Request.Cookies["username"] == null) { var cookie = new HttpCookie("username", user.UserName); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies["username"].Value = user.UserName; } Session["YeUser"] = user; Response.Redirect("Home.aspx");//登录后跳转 } }
protected void btnOK_OnClick(object sender, EventArgs e) { if (AdministratorBll.GetAdministrators().SingleOrDefault(a => a.Account == tbxAccount.Text) != null) { WebUtil.Alert("该用户名已存在!"); return; } else { if (AdministratorBll.AddAdministrator(new Ye_Administrator() { Account = tbxAccount.Text.Trim(), Password = DESUtil.Encrypt(tbxPwd1.Text.Trim()), CreateTime = DateTime.Now, LastLoginTime = DateTime.Now })) { AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = YeAdministratorId, LogTypeName = LogType.添加管理员.ToString(), CreateTime = DateTime.Now }); WebUtil.AlertAndReload("成功添加管理员!"); } else { WebUtil.Alert("创建新管理员时出错!"); } } }
/// <summary> /// 获取明文连接字符串 /// </summary> /// <param name="connectionString">连接字符串</param> /// <returns>明文连接字符串</returns> public string GetPlaintextConnectionString(string connectionString) { if (string.IsNullOrWhiteSpace(connectionString) || !ConnectionEncrypt) { return(connectionString); } return(DESUtil.Decrypt(connectionString)); }
public void DecryptDesTest() { var path = AppDomain.CurrentDomain.BaseDirectory + "\\upgrade.config.json"; var str = FileUtil.GetFileContent(path); var config = JsonHelper.JSONToObject <UpgradeConfig>(str); var result = DESUtil.DecryptDes(config.Encryptstr, key); var info = JsonHelper.JSONToObject <UpgradeInfo>(result); Console.WriteLine(result); }
//protected void btnSendSMS_OnClick(object sender, EventArgs e) //{ //} protected void btnRegister_OnClick(object sender, EventArgs e) { var user = new Ye_User() { Address = tbxAddress.Text.Trim(), UserName = tbxName.Text.Trim(), Zip = tbxZip.Text.Trim(), AptSuite = tbxAptSuite.Text.Trim(), Mobile = tbxPhone.Text.Trim(), Password = DESUtil.Encrypt(tbxPassword.Text.Trim()), Email = tbxEmail.Text.Trim(), FaceBookID = "", QQ = "", WxID = "", Status = 0, LastLoginTime = DateTime.Now, RegisterTime = DateTime.Now }; if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null) { WebUtil.Alert("The username is used,please change a new username.");//当前用户已经存在!请使用其他用户名注册! return; } if (UserBll.AddUser(user)) { Session["YeUser"] = UserBll.Login(user.UserName, user.Password); if (Request.Cookies["location"] == null) { var cookie = new HttpCookie("location", user.Address); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies["location"].Value = user.Address; } if (Request.Cookies["username"] == null) { var cookie = new HttpCookie("username", user.UserName); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Request.Cookies["username"].Value = user.UserName; } WebUtil.AlertAndRedirect("Register successfully", "Home.aspx"); } else { WebUtil.Alert("Failed to register."); } }
/// <summary> /// 获取默认的连接字符串 /// </summary> /// <returns>默认的连接字符串</returns> protected override string GetDefaultConnectionString() { var connString = AppConfig["MessageQueue:RabbitConnectionString"]; if (string.IsNullOrWhiteSpace(connString)) { return(connString); } return(ConfigUtil.ConnectionEncryption ? DESUtil.Decrypt(connString, AppConfig["DES:Key"], AppConfig["DES:IV"]) : connString); }
void Decry() { Stopwatch sw = new Stopwatch(); sw.Start(); var text = DESUtil.Decrypt(toDecry, key, iv); sw.Stop(); Debug.Log(sw.ElapsedMilliseconds); Debug.Log(text); }
/// <summary> /// 根据键获取连接字符串集合 /// </summary> /// <param name="key">键</param> /// <returns>连接字符串集合</returns> private string[] GetConnectionStrings(string key) { string value = AppConfig[key]; if (string.IsNullOrWhiteSpace(value)) { return(null); } string conns = ConnectionEncryption ? DESUtil.Decrypt(value, PlatformTool.AppConfig["DES:Key"], PlatformTool.AppConfig["DES:IV"]) : value; return(conns.Split('|')); }
/// <summary> /// 点击解密按钮 /// </summary> /// <param name="sender">引发对象</param> /// <param name="e">事件参数</param> private void btnDecode_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCiphertext.Text)) { MessageBox.Show("请输入密文"); return; } try { txtPlaintext.Text = DESUtil.Decrypt(txtCiphertext.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override void OnSuccess(WWW www) { Dictionary <string, object> plist = Plist.readPlist(DESUtil.Decrypt(www.bytes, FileUtil.sKey)) as Dictionary <string, object>; _sgAds = DictionaryUtil.GetDictionaryValue(plist, "Data", "SGAds"); List <object> InterstitialAds = DictionaryUtil.GetListValue(_sgAds, "InterstitialAds"); Dictionary <string, object> v1 = InterstitialAds [0] as Dictionary <string, object>; Debug.Log("InterstitialAdConfig ..... OnSuccess"); InterstitialAdLoader interstitialAdLoader = new InterstitialAdLoader(DictionaryUtil.GetStringValue(v1, "", IMAGE_URL), DictionaryUtil.GetStringValue(v1, "", APP_NAME), DictionaryUtil.GetStringValue(v1, "", APP_URL)); isOn = true; interstitialAdLoader.StartLoader(); Dictionary <string, object> BannerAds = DictionaryUtil.GetDictionaryValue(_sgAds, BANNER_ADS); iconsImageLoader = new SimpleZipDownloader(DictionaryUtil.GetStringValue(BannerAds, "", ICONS_URL), OnIconsLoad, false); iconsImageLoader.StartLoader(); _bannerInfos = DictionaryUtil.GetListValue(BannerAds, APPS_INFO); }
/// <summary> /// 创建连接且打开 /// </summary> /// <param name="connectionStringConfigName">连接字符串配置名称</param> /// <param name="messageQueueFilePath">消息队列文件路径</param> /// <param name="dataContentType">数据内容类型。只支持JSON和XML</param> /// <returns>连接</returns> public static IMessageQueueConnection CreateAndOpen(string connectionStringConfigName = null, string messageQueueFilePath = null, DataContentType dataContentType = DataContentType.JSON) { if (!(dataContentType == DataContentType.JSON || dataContentType == DataContentType.XML)) { throw new NotSupportedException("数据内容类型只支持JSON或XML"); } var conn = new RabbitAutoRecoveryConnection(); if (string.IsNullOrWhiteSpace(connectionStringConfigName)) { conn.Open(); } else { var connString = PlatformTool.AppConfig[connectionStringConfigName]; if (ConfigUtil.ConnectionEncryption) { connString = DESUtil.Decrypt(connString, PlatformTool.AppConfig["DES:Key"], PlatformTool.AppConfig["DES:IV"]); } conn.Open(connString); } if (!string.IsNullOrWhiteSpace(messageQueueFilePath)) { var rabbitConn = conn.ProtoConnection as RabbitConnection; var messageQueueInfoFactory = new RabbitMessageQueueInfoConfigFactory(); rabbitConn.MessageQueueInfoFactory = messageQueueInfoFactory; if (dataContentType == DataContentType.JSON) { messageQueueInfoFactory.MessageQueueReader = new RabbitMessageQueueJson(messageQueueFilePath); } else { messageQueueInfoFactory.MessageQueueReader = new RabbitMessageQueueXml(messageQueueFilePath); } } return(conn); }
protected void btnRegister_OnClick(object sender, EventArgs e) { var shop = new Ye_Shop() { ShopAccount = tbxUserName.Text.Trim(), ShopPassword = DESUtil.Encrypt(tbxUserPwd.Text.Trim()), RegisterTime = DateTime.Now, LastLoginTime = DateTime.Now, ShopName = tbxShopName.Text, ShopAddress = tbxAddr.Text, ShopMobile = tbxShopMobile.Text, ShopEmail = tbxShopEmail.Text, ShopFax = tbxShopFax.Text, ShopZip = tbxShopZip.Text, ShopDesc = "", ShopLogoImg = "", ShopMainImg = "", ShopQQ = "", ShopQRCodeImg = "", Longitude = 0, Latitude = 0, DeliveryTime = "", DeliveryMinPrice = 0, RecommendLevel = 0, IsChecked = false, OpeningBeginMinute = 0, OpeningEndMinute = 0, Rank = 3, Clicks = 0, }; if (ShopBll.AddShop(shop)) { WebUtil.AlertAndRedirect("您的餐馆已成功注册,请耐心等待审核!", "Login.aspx"); } else { WebUtil.Alert("餐馆注册失败!"); } }
public void EncryptTest() { var info = new UpgradeInfo { MainSite = new Site { Name = "AutoUpgradeTest", DefaultPage = "http://localhost:801/index.html", PhysicalPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest", Port = 801 }, DbConnStr = "server=zapdev.ticp.net\\dev,2989;uid=sa;pwd=Hz2017;database=Zapsoft_kx_test", UpgradePackages = new List <UpgradePackage> { new UpgradePackage { PackageID = Guid.Parse("6583bc9d-e1ff-4c0b-9625-78b27bedcd68"), PackageName = "1.0.1.zip", UnzipPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest\\UpgradePackage\\1.0.1\\", ZipPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest\\UpgradePackage\\1.0.1.zip", CopyPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest\\UpgradePackage\\1.0.1\\*", Version = "1.0.1" }, new UpgradePackage { PackageID = Guid.Parse("5A1B0FDA-F10E-4844-9092-F7FFBDE9D6C8"), PackageName = "1.0.2.zip", UnzipPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest\\UpgradePackage\\1.0.2\\", ZipPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest\\UpgradePackage\\1.0.2.zip", CopyPath = "E:\\03_ReleaseWebSite\\AutoUpgradeTest\\UpgradePackage\\1.0.2\\*", Version = "1.0.2" } } }; var encryptstr = JsonHelper.ObjectToJSON(info); var result = DESUtil.EncryptDES(encryptstr, key); FileUtil.Write("E:\\03_ReleaseWebSite\\AutoUpgradeTest\\upgrade.config.json", JsonHelper.ObjectToJSON(new UpgradeConfig { Encryptstr = result })); Console.WriteLine(result); }
protected void btnOK_OnClick(object sender, EventArgs e) { if (YeShop.ShopPassword != DESUtil.Encrypt(tbxOldPwd.Text)) { WebUtil.Alert("您输入的当期登录密码不正确!"); tbxOldPwd.Focus(); return; } else { var newPwd = DESUtil.Encrypt(tbxNewPwd1.Text.Trim()); if (ShopBll.ChangePassword(YeShopId, newPwd)) { WebUtil.Alert("密码修改成功!"); YeShop.ShopPassword = newPwd; } else { WebUtil.Alert("密码修改失败!"); } } }
protected void imgBtn_OnClick(object sender, ImageClickEventArgs e) { var user = new Ye_User() { Address = tbxAddress.Text.Trim(), UserName = tbxFirstName.Text.Trim() + " " + tbxLastName.Text.Trim(), //Zip = tbxZip.Text.Trim(), //Aptsuite = tbxAptSuite.Text.Trim(), Mobile = tbxMobile.Text.Trim(), Password = DESUtil.Encrypt(tbxPwd1.Text.Trim()), Email = tbxEmail.Text.Trim(), FaceBookID = "", QQ = "", WxID = "", Status = 0, Zip = "", AptSuite = "", LastLoginTime = DateTime.Now, RegisterTime = DateTime.Now }; if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null) { WebUtil.Alert("当前用户已经存在!请使用其他用户名注册!"); return; } if (UserBll.AddUser(user)) { Session["YeUser"] = UserBll.Login(user.UserName, user.Password); Response.Redirect("Home.aspx"); } else { WebUtil.Alert("注册失败!"); } }
private void btn_Encode_ItemClick(object sender, ItemClickEventArgs e) { String str = spreadsheetMain.ActiveCell.DisplayText; String key = DESUtil.GenerateKey(); String[] strs = new string[] { "Provider=IBMDA400;Data Source=172.31.96.210;User Id=ITSDTS;Password = STD008;", "Data Source=srf-sql;User Id=MARS_E;Password = rs@996t!ty", "Data Source=ichart3d;User Id=MARS_E;Password = rs@996t!ty", "Data Source=ichart3d;User Id=MARS_E;Password = rs@996t!ty" }; str = DESUtil.EncryptString(str, key); Console.WriteLine(str); foreach (string item in strs) { Console.WriteLine("//////////////////////"); Console.WriteLine(item); Console.WriteLine(" "); String tmp = DESUtil.EncryptString(item, key); Console.WriteLine(tmp); Console.WriteLine(" "); Console.WriteLine(DESUtil.DecryptString(tmp, key)); } }
public override void OnAuthorization(HttpActionContext actionContext) { if (!actionContext.Request.Headers.Contains("signature")) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "signature required"); } else { var des = new DESUtil(); try { string decrypted = des.Decrypt(actionContext.Request.Headers.GetValues("signature").First(), DESUtil.SECRET_TIMESTAMP_NONCE_AUTH); if (decrypted.Length < 11) //10位TimeStamp+Nonce { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "invalid signature string"); } else { long timeStamp = 0; int nonce = 0; long.TryParse(decrypted.Substring(0, 10), out timeStamp); int.TryParse(decrypted.Substring(10), out nonce); if (timeStamp == 0 || nonce == 0) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "invalid signature"); } else { // Get the request lifetime scope so you can resolve services. var requestScope = actionContext.Request.GetDependencyScope(); // Resolve the service you want to use. var db = requestScope.GetService(typeof(YJYEntities)) as YJYEntities; var record = db.TimeStampNonces.FirstOrDefault(o => o.Nonce == nonce && o.TimeStamp == timeStamp); if (record == null || record.UsedAt != null) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "signature unauthorized"); } else { record.UsedAt = DateTime.UtcNow; db.SaveChanges(); } } } } catch { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "signature checking failed"); } } base.OnAuthorization(actionContext); }
private void txt_Des_EditValueChanged(object sender, EventArgs e) { String input = txt_Des.Text; txt_Input.Text = DESUtil.DecryptString(input, DESUtil.GenerateKey()); }
public bool Login(string username, string password) { return(AdministratorBll.Login(username, DESUtil.Encrypt(password)) != null); }
public static string DecryptDES(this string str) { return(DESUtil.Decrypt(str)); }