From 112c9bd20afed95d582b7eb227075ab8d10cdd12 Mon Sep 17 00:00:00 2001 From: 海波 张 <2956280567@qq.com> Date: 星期二, 24 六月 2025 17:29:28 +0800 Subject: [PATCH] 金坛优化 --- util/HttpHelper.cs | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/util/HttpHelper.cs b/util/HttpHelper.cs index 545404f..797d4ca 100644 --- a/util/HttpHelper.cs +++ b/util/HttpHelper.cs @@ -3,13 +3,48 @@ using System.IO; using System.Linq; using System.Net; +using System.Security.Cryptography; using System.Text; namespace HH.WCS.ZhongCeJinTan.util { public class HttpHelper { + + /// <summary> + /// MD5鍔犲瘑 + /// </summary> + /// <param name="sInput"></param> + /// <returns></returns> + public static string GetMd5FromString(string sInput) + { + var lstData = Encoding.GetEncoding("utf-8").GetBytes(sInput); + var lstHash = new MD5CryptoServiceProvider().ComputeHash(lstData); + var result = new StringBuilder(32); + for (int i = 0; i < lstHash.Length; i++) + { + result.Append(lstHash[i].ToString("x2").ToUpper()); + } + return result.ToString(); + } + public string WebPost(string url, string postData, string cotentType = "application/json") { + + //閰嶇疆閴存潈 + //var AppKey = Settings.AppKey; + //var AppSecret = Settings.AppSecret; + ////鑾峰彇鏃堕棿鎴�+ //var ReqTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); + ////var ReqTime = GetTimeStamp(DateTime.Now.AddHours(-8), 1, 2); + //LogHelper.Info($"鍔犲瘑鍓�AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime} "); + //LogHelper.Info($"鍦板潃锛歿url},鍐呭锛歿postData}"); + //var ReqVerify = GetMd5FromString(AppKey + AppSecret + ReqTime); + //LogHelper.Info($"鍔犲瘑鍚�AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime} ReqVerify={ReqVerify} url={url} req={postData}"); + //request.Headers.Add("ReqTime", ReqTime.ToString()); + //request.Headers.Add("ReqVerify", ReqVerify); + //request.Headers.Add("AppKey", AppKey); + + Console.WriteLine(url); WebRequest request = WebRequest.Create(url); request.Method = "POST"; @@ -19,6 +54,8 @@ request.ContentLength = byteArray.Length; request.Timeout = 6000; + + try { Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); -- Gitblit v1.9.1