//[HttpGet] //public IActionResult GenKey() //{ // var str = CommonTools.CreateRandomStr(16); // str = "97AVsyHmvBJFGMXj"; // var data = EncryptTools.AESEncrypt(str + "|" + DateTime.Now.ToString("yyyyMMddHHmmss"), str); // var result = Convert.ToBase64String(Encoding.UTF8.GetBytes(data)); // return Json(new { key = str, token = result }); //} //[HttpGet] //public IActionResult Test() //{ // var order = new InterfaceOrderModel(); // order.PSerialNumber = "XX45513245556";//必填 // order.ShopId = 1;//后续给出(必填) // order.PayType = 120;//后续给出(必填) // order.PayMentType = 0;//填0即可(B2B订单需要) // order.PayDate = "20200918112455";//付款日期,传递过来格式"yyyyMMddHHmmss" // order.PayPrice = 200;//已付款金额(必填) // //order.IsNeedPaperBag = true;//是否需要纸袋 // order.DeliveryTypeId = 11;//后续给出(必填) // order.UserName = "";//商城购买者账号,需要关联的时候填写 // order.CustomerName = "任盈盈"; // order.CustomerPhone = "18776159649"; // order.CustomerAddressDetail = "广东省 深圳市 南山区 金融科技大厦12楼"; // order.CustomerMark = "尽快发货"; // order.AdminMark = "客服备注"; // order.ZMCoupon = 0; // order.ZMWineCoupon = 0; // order.WineWorldCoupon = 0; // order.ProductCoupon = ""; // order.ZMIntegralValuePrice = 0; // //发票信息 // InvoiceInfo invInfo = new InvoiceInfo(); // invInfo.CustomerEmail = "*****@*****.**";//客户用于发票接收邮箱 // invInfo.Title = "发票抬头"; // //发票中包含的增票部分 // invInfo.TaxpayerID = "45234234"; // invInfo.RegisterAddress = "广东省 深圳市 南山区 金融科技大厦12楼"; // invInfo.RegisterTel = "8588885"; // invInfo.BankOfDeposit = "广发 桃园支行"; // invInfo.BankAccount = "88888888888888"; // //商品 // List<InterFaceOrderProduct> proList = new List<InterFaceOrderProduct>(); // InterFaceOrderProduct pro = new InterFaceOrderProduct(); // pro.ProductCode = "Ferrari911"; // pro.ProductCode = "Ferrari911"; // pro.Quantity = 5; // pro.SumPrice = 200; // pro.Price = 80; // proList.Add(pro); // order.Products = proList; // order.InvoiceInfo = invInfo; // var data = new List<InterfaceOrderModel>(); // data.Add(order); // //order.InvoiceMode = item.InvoiceMode;//开票方式 // dynamic dd = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(GenKey())); // using (var http = new HttpClient()) // { // var data3 = new { orders = data, sign = dd, orderType = 1 }; // StringContent content = new StringContent(JsonConvert.SerializeObject(data3)); // var response = http.PostAsync("http://localhost:50444", content); // } // var cc = CreateOrderToOMS(data, (string)dd.Value["token"], 1); // return Json(cc); //} #endregion #region 验证部分 /// <summary> /// AES验证部分 /// </summary> /// <param name="sign"></param> /// <param name="key"></param> bool VerifySignature(string sign, string key) { /* ***************************************************************** * * sign字符串 Base64[AES(key|dateTime)] * dateTime 接口获取时间 误差3分钟 格式"yyyyMMddHHmmss" * key 双方约定密钥字符串 97AVsyHmvBJFGMXj * * *****************************************************************/ try { //反base64 var req = Convert.FromBase64String(sign); var str = Encoding.GetEncoding("utf-8").GetString(req); //解密 var res = EncryptTools.AESDecrypt(str, key); //判断 var result = res.Split("|"); var time = DateTime.ParseExact(result[1], "yyyyMMddHHmmss", null); if (result[0] == key && time.AddMinutes(3) >= DateTime.Now) { return(true); } return(false); } catch (Exception e) { return(false); } }
protected void Page_Load(object sender, EventArgs e) { string mobile = "13761138329"; string s1 = EncryptTools.AESEncrypt(mobile); Response.Write("加密结果:" + s1); Response.Write("<br/>解密结果:"); Response.Write(EncryptTools.AESDecrypt(s1)); }
public IActionResult UpdateUserPassword(string oldPassword, string newPassword, int id) { var user = _userService.GetById(id); if (user == null) { return(Error("数据错误,未找到该用户")); } var password = EncryptTools.AESDecrypt(user.UserPwd, user.Salt); if (oldPassword != password) { return(Error("旧密码输入错误")); } var salt = CommonTools.CreateRandomStr(16); user.Salt = salt; user.UserPwd = EncryptTools.AESEncrypt(newPassword, salt); user.ModifiedBy = _workContext.CurrentUser.Id; user.ModifiedTime = DateTime.Now; _userService.UpdateUser(user); return(Success()); }