这几句PHP代码,用ASP应该怎么写
ksort($params);
$str = urldecode(http_build_query($params));
$hash = mhash(MHASH_SHA256, $str, $keycode);
$params['sign'] = base64_encode($hash);
$url = "https://open.huawa.com/newapi/import%22;
$data = http_post($url, $params);
这几句PHP代码,用ASP怎么写
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
9条回答 默认 最新
threenewbee 2023-08-13 14:28关注获得1.50元问题酬金 这是对参数签名吧,需要调用SHA256
<%@ Language=VBScript %> <% ' Sorting the params dictionary Set params = CreateObject("Scripting.Dictionary") For Each x In Request.Form params(x) = Request.Form(x) Next Set keys = params.Keys keys.Sort ' Building the query string str = "" For Each key In keys val = Server.UrlEncode(params(key)) If str <> "" Then str = str & "&" End If str = str & key & "=" & val Next ' Calculating the hash Set crypto = Server.CreateObject("CAPICOM.HashedData") crypto.Algorithm = 8 ' SHA-256 crypto.SignedData = str & "&" & keycode hash = crypto.Value ' Encoding the hash with base64 Set base64 = Server.CreateObject("MSXML2.DomDocument") Set elem = base64.CreateElement("base64") elem.DataType = "bin.base64" elem.NodeTypedValue = hash encoded = elem.Text ' Adding the sign parameter params("sign") = encoded ' Sending the POST request Set http = Server.CreateObject("MSXML2.ServerXMLHTTP") url = "https://open.huawa.com/newapi/import" http.Open "POST", url, False http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" http.Send str ' Receiving the response responseText = http.responseText Response.Write responseText %>解决 无用评论 打赏 举报