diff --git a/COMCMS.API/COMCMS.API.csproj b/COMCMS.API/COMCMS.API.csproj new file mode 100644 index 0000000..b69fa4d --- /dev/null +++ b/COMCMS.API/COMCMS.API.csproj @@ -0,0 +1,11 @@ + + + + netcoreapp2.0 + + + + + + + diff --git a/COMCMS.Common/MySign.cs b/COMCMS.Common/MySign.cs index 5d3319a..f3a0ed0 100644 --- a/COMCMS.Common/MySign.cs +++ b/COMCMS.Common/MySign.cs @@ -28,7 +28,7 @@ namespace COMCMS.Common //NewLife.Log.XTrace.WriteLine("拼接字符:" + signdata); string mysign = Utils.MD5(signdata + Utils.SIGNSALT); //NewLife.Log.XTrace.WriteLine("签名:" + mysign); - return mysign == signature; + return mysign.ToUpper() == signature.ToUpper(); } #endregion diff --git a/COMCMS.Common/Utils.cs b/COMCMS.Common/Utils.cs index 7e999ae..472d2b0 100644 --- a/COMCMS.Common/Utils.cs +++ b/COMCMS.Common/Utils.cs @@ -40,8 +40,21 @@ namespace COMCMS.Common /// /// 与小程序验签的盐值 /// - public static readonly string SIGNSALT = ConfigurationManager.AppSettings["SignSalt"]; + public static readonly string SIGNSALT = "comcms";// ConfigurationManager.AppSettings["SignSalt"]; + + /// + /// 订单状态 "未确认", "已确认", "已完成", "已取消" + /// + public static string[] OrdersState = { "未确认", "已确认", "已完成", "已取消" }; + /// + /// 支付状态 { "未支付", "已支付", "已退款" } + /// + public static string[] PaymentState = { "未支付", "已支付", "已退款" }; + /// + /// 配送状态 "未配送", "配货中", "已配送", "已收到", "退货中", "已退货" + /// + public static string[] DeliverState = { "未配送", "配货中", "已配送", "已收到", "退货中", "已退货" }; #endregion #region 验证部分 @@ -97,6 +110,25 @@ namespace COMCMS.Common { return Regex.IsMatch(strUrl, @"^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$"); } + /// + /// 获取当前网站根目录网址 不带 / + /// + /// + public static string GetServerUrl() + { + string http = "http://"; + if (MyHttpContext.Current.Request.IsHttps) //判断是否是https + { + http = "https://"; + } + string port = MyHttpContext.Current.Request.Host.Port.ToString(); + if (port == "80" || port == "443") + return http + MyHttpContext.Current.Request.Host.Host; + else + return http + MyHttpContext.Current.Request.Host.Host + ":" + port; + + } + /// /// 判断是否为base64字符串 /// @@ -630,6 +662,30 @@ namespace COMCMS.Common } return "127.0.0.1"; } + + + /// + /// 时间戳转换成DateTime格式 + /// + /// + /// + public static DateTime StampToDateTime(string timeStamp) + { + DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); + long lTime = long.Parse(timeStamp + "0000"); + TimeSpan toNow = new TimeSpan(lTime); + return dateTimeStart.Add(toNow); + } + + /// + /// 获取时间戳 + /// + /// + public static string GetTimeStamp() + { + TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds).ToString(); + } #endregion #region 处理部分 diff --git a/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml index 1c0d6e3..0204468 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Index/Main.cshtml @@ -164,7 +164,7 @@ 服务器地址 - @ViewBag.remoteip + @Utils.GetServerUrl() @@ -174,7 +174,7 @@ - 网站IP + 本地IP地址 @Utils.GetIP() diff --git a/COMCMS.Web/COMCMS.Web.csproj b/COMCMS.Web/COMCMS.Web.csproj index bcf830c..03b687c 100644 --- a/COMCMS.Web/COMCMS.Web.csproj +++ b/COMCMS.Web/COMCMS.Web.csproj @@ -5,12 +5,14 @@ - + + + diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs index badc672..74b98ef 100644 --- a/COMCMS.Web/Controllers/HomeController.cs +++ b/COMCMS.Web/Controllers/HomeController.cs @@ -34,7 +34,7 @@ namespace COMCMS.Web.Controllers ViewBag.siteName = cfg.SiteName; ViewBag.c = CookiesHelper.GetCookie("abc"); - ViewBag.d = Utils.SIGNSALT; + ViewBag.d = Utils.GetServerUrl(); return View(); } diff --git a/COMCMS.Web/Controllers/api/APIBaseController.cs b/COMCMS.Web/Controllers/api/APIBaseController.cs new file mode 100644 index 0000000..51d0857 --- /dev/null +++ b/COMCMS.Web/Controllers/api/APIBaseController.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using COMCMS.Common; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace COMCMS.Web.Controllers.api +{ + [Produces("application/json")] + public class APIBaseController : Controller + { + #region 通用信息 + public ReJSON reJson = new ReJSON(); + #endregion + + #region 验证签名 + public bool CheckSignature(SortedDictionary pars, string signature) + { + if (!MySign.CheckSign(pars, signature)) + { + reJson.code = 40004; + reJson.message = "signature 错误!"; + return false; + } + //判断是否超时 + string timeStamp = pars["timeStamp"]; + //判断时间有效性 + DateTime postTime = Utils.StampToDateTime(timeStamp); + if (postTime < DateTime.Now.AddSeconds(-120))//30秒有效期 + { + reJson.code = 40004; + reJson.message = "数据请求超时!"; + reJson.isReload = 1; + return false; + } + return true; + } + + #endregion + + #region 自动验证QueryString 的签名 + /// + /// 自动验证QueryString 的签名 + /// + /// + public bool AutoCheckQueryStringSignature() + { + var queryStrings = Request.Query; + List keys = new List(); + //string[] keys = HttpContext.Current.Request.QueryString.AllKeys; + if (queryStrings == null) + { + return false; + } + foreach (var item in queryStrings.Keys) + { + keys.Add(item); + } + SortedDictionary pars = new SortedDictionary(); + string signature = ""; + foreach (var k in keys) + { + if (k != "signature") + { + string v = Request.Query[k]; + pars.Add(k, v); + } + else + { + signature = Request.Query[k]; + } + } + //没有签名返回错误 + if (string.IsNullOrEmpty(signature)) + return false; + return CheckSignature(pars, signature); + } + #endregion + } + + #region 通用返回信息 + public class ReJSON + { + /// + /// 返回代码 0 为正确 + /// + public int code { get; set; } = 40000; + + /// + /// 提示语 + /// + public string message { get; set; } + /// + /// 是否重新加载 + /// + public int isReload { get; set; } = 0; + + /// + /// 数据详情 object + /// + public object detail { get; set; } + } + #endregion +} \ No newline at end of file diff --git a/COMCMS.Web/Controllers/api/IndexController.cs b/COMCMS.Web/Controllers/api/IndexController.cs index 3e13767..fbb0be3 100644 --- a/COMCMS.Web/Controllers/api/IndexController.cs +++ b/COMCMS.Web/Controllers/api/IndexController.cs @@ -11,8 +11,8 @@ using XCode; namespace COMCMS.Web.Controllers.api { - [Route("api/[controller]")] - public class IndexController : Controller + [Route("api/[controller]/[action]")] + public class IndexController : APIBaseController { // GET: api/ [HttpGet] @@ -22,11 +22,30 @@ namespace COMCMS.Web.Controllers.api return cfg; } - // GET api//5 - [HttpGet("{id}")] - public string Get(int id) + #region 测试验签 + /// + /// 测试验签 + /// + /// id + /// + /// + /// + /// + [HttpGet] + public object CheckSign(string id, string random = "", string timeStamp = "", string signature = "") { - return "value"; + if (!AutoCheckQueryStringSignature()) + { + reJson.message = "验签失败!"; + return reJson; + } + else + { + reJson.code = 0; + reJson.message = "验签成功!"; + return reJson; + } } + #endregion } } diff --git a/COMCMS.Web/Controllers/api/PaymentController.cs b/COMCMS.Web/Controllers/api/PaymentController.cs new file mode 100644 index 0000000..ad690bb --- /dev/null +++ b/COMCMS.Web/Controllers/api/PaymentController.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using COMCMS.Common; +using COMCMS.Core; +using XCode; +using NewLife.Log; +using Senparc.Weixin.MP; +using Senparc.Weixin.MP.TenPayLibV3; +using Newtonsoft.Json; + +namespace COMCMS.Web.Controllers.api +{ + /// + /// 支付API + /// + [Produces("application/json")] + [Route("api/Payment")] + public class PaymentController : APIBaseController + { + #region 微信小程序订单支付 + [HttpGet] + public object DoPayOrder(string ordernum, string random = "", string timeStamp = "", string signature = "") + { + if (!AutoCheckQueryStringSignature()) + { + return reJson; + } + + //获取订单 + Order entity = Order.Find(Order._.OrderNum == ordernum); + if (entity == null) + { + reJson.code = 40000; + reJson.message = "系统找不到本订单!"; + return reJson; + } + //判断订单状态 + if (entity.OrderStatus == Utils.OrdersState[3]) + { + reJson.code = 40000; + reJson.message = "已完成订单不允许支付!"; + return reJson; + } + if (entity.PaymentStatus != Utils.PaymentState[0]) + { + reJson.code = 40000; + reJson.message = "当前订单支付状态不允许支付!"; + return reJson; + } + //获取用户并判断是否是已经注册用户 + Member my = Member.FindById(entity.UId); + if (my == null || string.IsNullOrEmpty(my.WeixinAppOpenId)) + { + reJson.code = 40000; + reJson.message = "用户状态错误,无法使用本功能!"; + return reJson; + } + //开始生成支付订单 + OnlinePayOrder model = new OnlinePayOrder(); + model.OrderId = entity.Id; + model.OrderNum = entity.OrderNum; + model.PayId = 1; + model.PaymentNotes = "微信支付"; + model.PaymentStatus = Utils.PaymentState[0]; + model.PayOrderNum = Utils.GetOrderNum();//在线支付订单的订单号 + model.PayType = "微信支付"; + model.TotalPrice = entity.TotalPay; + model.TotalQty = entity.TotalQty; + model.UId = entity.UId; + model.IP = Utils.GetIP(); + model.IsOK = 0; + model.AddTime = DateTime.Now; + model.Insert(); + + //写入日志 + OrderLog log = new OrderLog(); + log.AddTime = DateTime.Now; + log.OrderId = entity.Id; + log.OrderNum = entity.OrderNum; + log.UId = entity.UId; + log.Actions = "用户使用微信支付;支付订单号:" + model.PayOrderNum; + log.Insert(); + + Core.Config cfg = Core.Config.GetSystemConfig(); + string appId = cfg.WXAppId;// ConfigurationManager.AppSettings["WeixinAppId"]; + string appSecrect = cfg.WXAppSecret;// ConfigurationManager.AppSettings["WeixinAppSecrect"]; + string wxmchId = cfg.MCHId;// ConfigurationManager.AppSettings["WeixinMCHId"]; + string wxmchKey = cfg.MCHKey;// ConfigurationManager.AppSettings["WeixinMCHKey"]; + + + + TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey, Utils.GetServerUrl() + "/wxpayment/notify"); + TenPayV3Info.TenPayV3Notify = Utils.GetServerUrl() + "/wxpayment/notify"; + XTrace.WriteLine("微信支付异步通知地址:" + TenPayV3Info.TenPayV3Notify); + //创建支付应答对象 + RequestHandler packageReqHandler = new RequestHandler(null); + var sp_billno = DateTime.Now.ToString("HHmmss") + TenPayV3Util.BuildRandomStr(26);//最多32位 + var nonceStr = TenPayV3Util.GetNoncestr(); + string rtimeStamp = Utils.GetTimeStamp(); + + //创建请求统一订单接口参数 + var xmlDataInfo = new TenPayV3UnifiedorderRequestData(TenPayV3Info.AppId, TenPayV3Info.MchId, entity.Title, model.PayOrderNum, (int)(entity.TotalPay * 100), Utils.GetIP(), TenPayV3Info.TenPayV3Notify, TenPayV3Type.JSAPI, my.WeixinAppOpenId, TenPayV3Info.Key, nonceStr); + + //返回给微信的请求 + RequestHandler res = new RequestHandler(null); + try + { + //调用统一订单接口 + var result = TenPayV3.Unifiedorder(xmlDataInfo); + XTrace.WriteLine("微信支付统一下单返回:" + JsonConvert.SerializeObject(result)); + + if (result.return_code == "FAIL") + { + reJson.code = 40005; + reJson.message = result.return_msg; + return reJson; + } + string nativeReqSign = res.CreateMd5Sign("key", TenPayV3Info.Key); + //https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=3 + //paySign = MD5(appId=wxd678efh567hg6787&nonceStr=5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id=wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key=qazwsxedcrfvtgbyhnujmikolp111111) + string paySign = Utils.MD5($"appId={TenPayV3Info.AppId}&nonceStr={nonceStr}&package=prepay_id={result.prepay_id}&signType=MD5&timeStamp={rtimeStamp}&key={TenPayV3Info.Key}").ToUpper(); + + string package = $"prepay_id={result.prepay_id}"; + + dynamic detail = new { timeStamp = rtimeStamp, nonceStr = nonceStr, package = package, signType = "MD5", paySign = paySign }; + + reJson.code = 0; + reJson.message = "下单成功!"; + reJson.detail = detail; + return reJson; + } + catch (Exception ex) + { + res.SetParameter("return_code", "FAIL"); + res.SetParameter("return_msg", "统一下单失败"); + XTrace.WriteLine($"统一下单失败:{ex.Message}"); + + reJson.code = 40005; + reJson.message = "统一下单失败,请联系管理员!"; + return reJson; + } + } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Web/Views/Home/About.cshtml b/COMCMS.Web/Views/Home/About.cshtml index 3674e37..7b6fb6c 100644 --- a/COMCMS.Web/Views/Home/About.cshtml +++ b/COMCMS.Web/Views/Home/About.cshtml @@ -5,3 +5,87 @@

@ViewData["Message"]

Use this area to provide additional information.

+ + \ No newline at end of file diff --git a/COMCMS.Web/wwwroot/favicon.ico b/COMCMS.Web/wwwroot/favicon.ico index a3a7999..c0ad48c 100644 Binary files a/COMCMS.Web/wwwroot/favicon.ico and b/COMCMS.Web/wwwroot/favicon.ico differ diff --git a/COMCMS.Web/wwwroot/js/md5.js b/COMCMS.Web/wwwroot/js/md5.js new file mode 100644 index 0000000..762de3c --- /dev/null +++ b/COMCMS.Web/wwwroot/js/md5.js @@ -0,0 +1,280 @@ +/* + * JavaScript MD5 + * https://github.com/blueimp/JavaScript-MD5 + * + * Copyright 2011, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * https://opensource.org/licenses/MIT + * + * Based on + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for more info. + */ + +/* global define */ + +;(function ($) { + 'use strict' + + /* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ + function safeAdd (x, y) { + var lsw = (x & 0xffff) + (y & 0xffff) + var msw = (x >> 16) + (y >> 16) + (lsw >> 16) + return (msw << 16) | (lsw & 0xffff) + } + + /* + * Bitwise rotate a 32-bit number to the left. + */ + function bitRotateLeft (num, cnt) { + return (num << cnt) | (num >>> (32 - cnt)) + } + + /* + * These functions implement the four basic operations the algorithm uses. + */ + function md5cmn (q, a, b, x, s, t) { + return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b) + } + function md5ff (a, b, c, d, x, s, t) { + return md5cmn((b & c) | (~b & d), a, b, x, s, t) + } + function md5gg (a, b, c, d, x, s, t) { + return md5cmn((b & d) | (c & ~d), a, b, x, s, t) + } + function md5hh (a, b, c, d, x, s, t) { + return md5cmn(b ^ c ^ d, a, b, x, s, t) + } + function md5ii (a, b, c, d, x, s, t) { + return md5cmn(c ^ (b | ~d), a, b, x, s, t) + } + + /* + * Calculate the MD5 of an array of little-endian words, and a bit length. + */ + function binlMD5 (x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << (len % 32) + x[((len + 64) >>> 9 << 4) + 14] = len + + var i + var olda + var oldb + var oldc + var oldd + var a = 1732584193 + var b = -271733879 + var c = -1732584194 + var d = 271733878 + + for (i = 0; i < x.length; i += 16) { + olda = a + oldb = b + oldc = c + oldd = d + + a = md5ff(a, b, c, d, x[i], 7, -680876936) + d = md5ff(d, a, b, c, x[i + 1], 12, -389564586) + c = md5ff(c, d, a, b, x[i + 2], 17, 606105819) + b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330) + a = md5ff(a, b, c, d, x[i + 4], 7, -176418897) + d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426) + c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341) + b = md5ff(b, c, d, a, x[i + 7], 22, -45705983) + a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416) + d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417) + c = md5ff(c, d, a, b, x[i + 10], 17, -42063) + b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162) + a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682) + d = md5ff(d, a, b, c, x[i + 13], 12, -40341101) + c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290) + b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329) + + a = md5gg(a, b, c, d, x[i + 1], 5, -165796510) + d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632) + c = md5gg(c, d, a, b, x[i + 11], 14, 643717713) + b = md5gg(b, c, d, a, x[i], 20, -373897302) + a = md5gg(a, b, c, d, x[i + 5], 5, -701558691) + d = md5gg(d, a, b, c, x[i + 10], 9, 38016083) + c = md5gg(c, d, a, b, x[i + 15], 14, -660478335) + b = md5gg(b, c, d, a, x[i + 4], 20, -405537848) + a = md5gg(a, b, c, d, x[i + 9], 5, 568446438) + d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690) + c = md5gg(c, d, a, b, x[i + 3], 14, -187363961) + b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501) + a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467) + d = md5gg(d, a, b, c, x[i + 2], 9, -51403784) + c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473) + b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734) + + a = md5hh(a, b, c, d, x[i + 5], 4, -378558) + d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463) + c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562) + b = md5hh(b, c, d, a, x[i + 14], 23, -35309556) + a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060) + d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353) + c = md5hh(c, d, a, b, x[i + 7], 16, -155497632) + b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640) + a = md5hh(a, b, c, d, x[i + 13], 4, 681279174) + d = md5hh(d, a, b, c, x[i], 11, -358537222) + c = md5hh(c, d, a, b, x[i + 3], 16, -722521979) + b = md5hh(b, c, d, a, x[i + 6], 23, 76029189) + a = md5hh(a, b, c, d, x[i + 9], 4, -640364487) + d = md5hh(d, a, b, c, x[i + 12], 11, -421815835) + c = md5hh(c, d, a, b, x[i + 15], 16, 530742520) + b = md5hh(b, c, d, a, x[i + 2], 23, -995338651) + + a = md5ii(a, b, c, d, x[i], 6, -198630844) + d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415) + c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905) + b = md5ii(b, c, d, a, x[i + 5], 21, -57434055) + a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571) + d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606) + c = md5ii(c, d, a, b, x[i + 10], 15, -1051523) + b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799) + a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359) + d = md5ii(d, a, b, c, x[i + 15], 10, -30611744) + c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380) + b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649) + a = md5ii(a, b, c, d, x[i + 4], 6, -145523070) + d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379) + c = md5ii(c, d, a, b, x[i + 2], 15, 718787259) + b = md5ii(b, c, d, a, x[i + 9], 21, -343485551) + + a = safeAdd(a, olda) + b = safeAdd(b, oldb) + c = safeAdd(c, oldc) + d = safeAdd(d, oldd) + } + return [a, b, c, d] + } + + /* + * Convert an array of little-endian words to a string + */ + function binl2rstr (input) { + var i + var output = '' + var length32 = input.length * 32 + for (i = 0; i < length32; i += 8) { + output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff) + } + return output + } + + /* + * Convert a raw string to an array of little-endian words + * Characters >255 have their high-byte silently ignored. + */ + function rstr2binl (input) { + var i + var output = [] + output[(input.length >> 2) - 1] = undefined + for (i = 0; i < output.length; i += 1) { + output[i] = 0 + } + var length8 = input.length * 8 + for (i = 0; i < length8; i += 8) { + output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32) + } + return output + } + + /* + * Calculate the MD5 of a raw string + */ + function rstrMD5 (s) { + return binl2rstr(binlMD5(rstr2binl(s), s.length * 8)) + } + + /* + * Calculate the HMAC-MD5, of a key and some data (raw strings) + */ + function rstrHMACMD5 (key, data) { + var i + var bkey = rstr2binl(key) + var ipad = [] + var opad = [] + var hash + ipad[15] = opad[15] = undefined + if (bkey.length > 16) { + bkey = binlMD5(bkey, key.length * 8) + } + for (i = 0; i < 16; i += 1) { + ipad[i] = bkey[i] ^ 0x36363636 + opad[i] = bkey[i] ^ 0x5c5c5c5c + } + hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8) + return binl2rstr(binlMD5(opad.concat(hash), 512 + 128)) + } + + /* + * Convert a raw string to a hex string + */ + function rstr2hex (input) { + var hexTab = '0123456789abcdef' + var output = '' + var x + var i + for (i = 0; i < input.length; i += 1) { + x = input.charCodeAt(i) + output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f) + } + return output + } + + /* + * Encode a string as utf-8 + */ + function str2rstrUTF8 (input) { + return unescape(encodeURIComponent(input)) + } + + /* + * Take string arguments and return either raw or hex encoded strings + */ + function rawMD5 (s) { + return rstrMD5(str2rstrUTF8(s)) + } + function hexMD5 (s) { + return rstr2hex(rawMD5(s)) + } + function rawHMACMD5 (k, d) { + return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d)) + } + function hexHMACMD5 (k, d) { + return rstr2hex(rawHMACMD5(k, d)) + } + + function md5 (string, key, raw) { + if (!key) { + if (!raw) { + return hexMD5(string) + } + return rawMD5(string) + } + if (!raw) { + return hexHMACMD5(key, string) + } + return rawHMACMD5(key, string) + } + + if (typeof define === 'function' && define.amd) { + define(function () { + return md5 + }) + } else if (typeof module === 'object' && module.exports) { + module.exports = md5 + } else { + $.md5 = md5 + } +})(this) diff --git a/COMCMS.Web/wwwroot/js/md5.min.js b/COMCMS.Web/wwwroot/js/md5.min.js new file mode 100644 index 0000000..7d8a3f5 --- /dev/null +++ b/COMCMS.Web/wwwroot/js/md5.min.js @@ -0,0 +1,2 @@ +!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)]=r;var e,i,a,d,h,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e>5]>>>t%32&255);return r}function d(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(o=i(o,8*n.length)),r=0;r<16;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(d(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="";for(r=0;r>>4&15)+"0123456789abcdef".charAt(15&t);return e}function v(n){return unescape(encodeURIComponent(n))}function m(n){return h(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}"function"==typeof define&&define.amd?define(function(){return A}):"object"==typeof module&&module.exports?module.exports=A:n.md5=A}(this); +//# sourceMappingURL=md5.min.js.map \ No newline at end of file diff --git a/COMCMS_NETCORE.sln b/COMCMS_NETCORE.sln index a18dc3b..da57a05 100644 --- a/COMCMS_NETCORE.sln +++ b/COMCMS_NETCORE.sln @@ -7,10 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COMCMS.Web", "COMCMS.Web\CO EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COMCMS.Core", "COMCMS.Core\COMCMS.Core.csproj", "{280AD487-F41E-42F7-95E7-187164485AD4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COMCMS.Common", "COMCMS.Common\COMCMS.Common.csproj", "{B282EB59-2330-4834-8F0A-6369F5A0288B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COMCMS.Common", "COMCMS.Common\COMCMS.Common.csproj", "{B282EB59-2330-4834-8F0A-6369F5A0288B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XCoder(代码生成器)", "XCoder\XCoder(代码生成器).csproj", "{71539325-194B-4D56-8D88-562B33004406}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COMCMS.API", "COMCMS.API\COMCMS.API.csproj", "{ED1581D0-7E94-4ADC-B2B4-0A523EA3B512}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {71539325-194B-4D56-8D88-562B33004406}.Debug|Any CPU.Build.0 = Debug|Any CPU {71539325-194B-4D56-8D88-562B33004406}.Release|Any CPU.ActiveCfg = Release|Any CPU {71539325-194B-4D56-8D88-562B33004406}.Release|Any CPU.Build.0 = Release|Any CPU + {ED1581D0-7E94-4ADC-B2B4-0A523EA3B512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED1581D0-7E94-4ADC-B2B4-0A523EA3B512}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED1581D0-7E94-4ADC-B2B4-0A523EA3B512}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED1581D0-7E94-4ADC-B2B4-0A523EA3B512}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE