{"id":854,"date":"2024-11-07T10:19:41","date_gmt":"2024-11-07T02:19:41","guid":{"rendered":"https:\/\/fwq.ai\/blog\/854\/"},"modified":"2024-11-07T10:19:41","modified_gmt":"2024-11-07T02:19:41","slug":"%e5%a6%82%e4%bd%95%e5%b0%86-php-python-%e4%b8%ad%e5%af%b9%e5%ad%97%e5%85%b8%e8%bf%9b%e8%a1%8c%e6%8e%92%e5%ba%8f%e5%b9%b6%e7%94%9f%e6%88%90%e7%ad%be%e5%90%8d%e7%9a%84%e4%bb%a3%e7%a0%81%e8%bd%ac","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/854\/","title":{"rendered":"\u5982\u4f55\u5c06 PHP\/Python \u4e2d\u5bf9\u5b57\u5178\u8fdb\u884c\u6392\u5e8f\u5e76\u751f\u6210\u7b7e\u540d\u7684\u4ee3\u7801\u8f6c\u6362\u6210 Golang\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1057\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173009261235856.jpg\" width=\"720\" height=\"288\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173009261235856.jpg 720w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173009261235856-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173009261235856-670x268.jpg 670w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" title=\"\u5982\u4f55\u5c06 PHP\/Python \u4e2d\u5bf9\u5b57\u5178\u8fdb\u884c\u6392\u5e8f\u5e76\u751f\u6210\u7b7e\u540d\u7684\u4ee3\u7801\u8f6c\u6362\u6210 Golang\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5c06 PHP\/Python \u4e2d\u5bf9\u5b57\u5178\u8fdb\u884c\u6392\u5e8f\u5e76\u751f\u6210\u7b7e\u540d\u7684\u4ee3\u7801\u8f6c\u6362\u6210 Golang\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>php \/ python \u4ee3\u7801\u8f6c golang<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong> \u5982\u4f55\u5c06 php\/python \u4e2d\u5bf9\u5b57\u5178\u8fdb\u884c\u6392\u5e8f\u5e76\u751f\u6210\u7b7e\u540d\u7684\u4ee3\u7801\u8f6c\u6362\u6210 golang\uff1f<\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<p><strong>golang \u4ee3\u7801\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201cPHP\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b<\/p>\n<pre>package main\n\nimport (\n    \"crypto\/md5\"\n    \"encoding\/hex\"\n    \"fmt\"\n    \"net\/url\"\n    \"sort\"\n)\n\nfunc main() {\n    \/\/ \u539f\u59cb\u53c2\u6570\u5b57\u5178\n    params := map[string]string{\n        \"x\": \"\u6709\u4e2d\u6587\u6709\u7b26!@ 2\u53f7\u7a7a\u683chttp:\/\/aaa.com\",\n        \"y\":  \"1\",\n        \"a\": \"{\"a1\":222,\"a2\":\"\\u4e2d\\u6587\"}\",\n    }\n\n    \/\/ \u5347\u5e8f\u6392\u5e8f Key\n    keys := make([]string, 0, len(params))\n    for k := range params {\n        keys = append(keys, k)\n    }\n    sort.Strings(keys)\n\n    \/\/ \u62fc\u63a5\n    data := url.Values{}\n    for _, k := range keys {\n        data.Add(k, params[k])\n    }\n\n    \/\/ URL \u7f16\u7801\n    encodedParams := data.Encode()\n\n    \/\/ MD5\n    signKey := \"abc\"\n    signData := encodedParams + signKey\n    hash := md5.New()\n    hash.Write([]byte(signData))\n    bytes := hash.Sum(nil)\n    sign := hex.EncodeToString(bytes)\n\n    \/\/ \u7ed3\u679c\uff1a18cebcb0d00d0c48904fd4b06ed0319d\n    fmt.Println(sign)\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728 golang \u548c python \u4e2d\uff0cuxxxx \u4f1a\u88ab\u8bc6\u522b\u4e3a unicode \u8f6c\u4e49\u5b57\u7b26\uff0c\u9700\u8981\u8f6c\u4e49\u4e3a uxxxx\u3002<\/li>\n<li>python \u4e2d\u7684\u7ed3\u679c\u4e0e php \u4e0d\u540c\uff0c\u662f\u56e0\u4e3a php \u5c06 uxxxx \u89c6\u4e3a\u666e\u901a\u5b57\u7b26\u4e32\uff0c\u800c python \u5c06\u5176\u89c6\u4e3a unicode \u8f6c\u4e49\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5c06 PHP\/Python \u4e2d\u5bf9\u5b57\u5178\u8fdb\u884c\u6392\u5e8f\u5e76\u751f\u6210\u7b7e\u540d\u7684\u4ee3\u7801\u8f6c\u6362\u6210 Golang\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>php \/ python \u4ee3\u7801\u8f6c golang \u95ee\u9898\uff1a \u5982\u4f55\u5c06 php\/python \u4e2d\u5bf9\u5b57\u5178\u8fdb\u884c\u6392\u5e8f\u5e76\u751f\u6210\u7b7e\u540d\u7684\u4ee3\u7801\u8f6c\u6362\u6210 golang\uff1f \u89e3\u7b54\uff1a golang \u4ee3\u7801\uff1a \u7acb\u5373\u5b66\u4e60\u201cPHP\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b package main import ( &#8220;crypto\/md5&#8221; &#8220;encoding\/hex&#8221; &#8220;fmt&#8221; &#8220;net\/url&#8221; &#8220;sort&#8221; ) func main() { \/\/ \u539f\u59cb\u53c2\u6570\u5b57\u5178 params := map[string]string{ &#8220;x&#8221;: &#8220;\u6709\u4e2d\u6587\u6709\u7b26!@ 2\u53f7\u7a7a\u683chttp:\/\/aaa.com&#8221;, &#8220;y&#8221;: &#8220;1&#8221;, &#8220;a&#8221;: &#8220;{&#8220;a1&#8243;:222,&#8221;a2&#8243;:&#8221;\\u4e2d\\u6587&#8243;}&#8221;, } \/\/ \u5347\u5e8f\u6392\u5e8f Key keys := make([]string, 0, len(params)) for k := range params { keys [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-854","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=854"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/854\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}