In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to use the format of url key-value pairs in dictionary order to concatenate a string md5 encrypted signature, the editor thinks it is very practical, so I share it for you to learn. I hope you can get something after reading this article, without saying much, let's take a look at it.
Concatenate all incoming non-null parameters into the string string1 in lexicographical order using the format of url key-value pairs
String string1 = key1=value1&key2=value2..
The string string2 is obtained by splicing the signature at the end of the string string1.
String string2 = string2 + & key name = 8934e7d15453e97507ef794cf7b0519d
Then encrypt the string2 with MD5, and convert the encrypted 32-bit string to uppercase. The resulting value is key_sign.
$payConfig = array ('pay_ver' = >' 1009, 'pay_type' = >' 010', 'service_id' = >' 015', 'merchant_no' = >', 'terminal_id' = >', 'terminal_trace' = > $orderInfo [' order_id'], 'terminal_time' = > date ("YmdHis") 'total_fee' = > $totalFee,' sub_appid' = >'', 'open_id' = > $openid,' notify_url' = > "http://www.demo.com") $access_token = "da3c47c2a8cd47e9be0868712dae0000"; $payConfig ['key_sign'] = self::getSign ($payConfig, $access_token); / / signed function getSign ($payConfig, $key) {ksort ($payConfig); $str = ""; foreach ($payConfig as $k = > $v) {$str = $str. $k. "=". $v. "&";} $str=$str. "access_token=". $key; return strtoupper (md5 ($str));} / / submit function postPay ($post_data) {$postUrl = ""; $curl = curl_init () Curl_setopt_array ($curl, array (CURLOPT_URL = > $postUrl, CURLOPT_RETURNTRANSFER = > true, CURLOPT_ENCODING = > "", CURLOPT_MAXREDIRS = > 10, CURLOPT_TIMEOUT = > 0, CURLOPT_FOLLOWLOCATION = > false, CURLOPT_HTTP_VERSION = > CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST = > "POST" CURLOPT_POSTFIELDS = > json_encode ($post_data), CURLOPT_HTTPHEADER = > array ("Content-Type: application/json"),) $response = curl_exec ($curl); var_dump ($response); curl_close ($curl); return $response;} above is how to use the format of url key-value pairs in lexicographical order to assemble a string md5 encrypted signature. Xiaobian believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.