{"id":596,"date":"2019-07-17T16:42:08","date_gmt":"2019-07-17T08:42:08","guid":{"rendered":"http:\/\/blog.yyhcw.com\/?p=596"},"modified":"2019-07-19T15:58:04","modified_gmt":"2019-07-19T07:58:04","slug":"php%e5%85%b3%e4%ba%8e%e5%9b%bd%e5%af%86sm3%e5%8a%a0%e5%af%86%e7%9a%84%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"http:\/\/blog.yyhcw.com\/post\/596.html","title":{"rendered":"PHP\u5173\u4e8e\u56fd\u5bc6SM3\u52a0\u5bc6\u7684\u5904\u7406"},"content":{"rendered":"<!--wp-compress-html--><!--wp-compress-html no compression--><p>\u8fd9\u51e0\u5929\u5bf9\u63a5\u4e2d\u56fd<a href=\"http:\/\/blog.yyhcw.com\">\u8054\u901a\u7269\u8054\u7f51<\/a>IoT Gateway\u95e8\u6237API\u7cfb\u7edf\uff0c\u5176\u4e2d\u7528\u5230\u56fd\u5bc6SM3\uff0c\u5176\u63d0\u4f9b\u7684token\u9700\u4f7f\u7528\u56fd\u5bc6SM3\u5bf9\u6e90\u4e32\u8fdb\u884c\u52a0\u5bc6\u5904\u7406\uff0c\u7f51\u4e0a\u641c\u7d22\u4e5f\u6ca1\u627e\u5230\u4ec0\u4e48\u51fd\u6570\u4e4b\u7c7b\u7684\uff0c\u53ea\u6709c\u548cjava\u8bed\u8a00\u5199\u7684\uff0c\u770b\u6765\u8981\u4f7f\u7528\u8fd9\u4e2aSM3\u52a0\u5bc6\u5c31\u5fc5\u987b\u8fdb\u884c\u6269\u5c55\u4e86\uff1b\u7531\u4e8e\u4e4b\u524d\u6ca1\u641e\u8fc7\u518d\u8005\u53c8\u6ca1\u627e\u5230\uff0c\u90fd\u60f3\u653e\u5f03\u4e86\uff0c\u5076\u7136\u53d1\u73b0\u4e86\uff1aa php extension for sm3(\u5b9e\u73b0sm3\u7b97\u6cd5\u7684php\u6269\u5c55)\u3010<a href=\"https:\/\/github.com\/luzhuqun\/php-sm3\">git \u5730\u5740<\/a>\u3011 OK\u4e86\uff0c\u5c31\u4ed6\u4e86\uff0c\u8fdb\u884c\u6d4b\u8bd5\uff01<\/p>\n<h1>php-sm3<\/h1>\n<h3>a php extension for sm3(\u5b9e\u73b0sm3\u7b97\u6cd5\u7684php\u6269\u5c55)<\/h3>\n<p>\u5b89\u88c5\u6b65\u9aa4<\/p>\n<ol>\n<li>git clone\u8be5\u9879\u76ee\u5230\u4f60\u7684linux php\u6e90\u7801ext\u76ee\u5f55\u4e0b\uff08\u53ef\u4ee5\u662f\u4efb\u610f\u76ee\u5f55 \uff09.<br \/>\n\u5982\uff1a[root@localhost home]# git clone https:\/\/github.com\/luzhuqun\/php-sm3.git<\/li>\n<li>\u8fdb\u5165sm3\u6269\u5c55\uff0c\u6267\u884c\/usr\/local\/php\/bin\/phpize<br \/>\n\u5982\uff1a[root@localhost home]# cd php-sm3<br \/>\n[root@localhost php-sm3]# \/www\/server\/php\/72\/bin\/phpize\u00a0 (\u6211\u4f7f\u7528\u7684<a href=\"http:\/\/\u5b9d\u5854\u670d\u52a1\u5668\u9762\u677f\uff0c\u4e00\u952e\u5168\u80fd\u90e8\u7f72\u53ca\u7ba1\u7406\uff0c\u9001\u4f603188\u5143\u793c\u5305\uff0c\u70b9\u6211\u9886\u53d6https:\/\/www.bt.cn\/?invite_code=MV94enhyc2s=\">\u5b9d\u5854\u9762\u677f<\/a>)<\/li>\n<li>.\/configure --with-php-config=\/usr\/local\/php\/bin\/php-config<br \/>\n\u5982\uff1a[root@localhost php-sm3]# .\/configure --with-php-config=\/www\/server\/php\/72\/bin\/php-config<\/li>\n<li>make &amp;&amp; make install<br \/>\n\u5982\uff1a[root@localhost php-sm3]# make &amp;&amp; make install<\/li>\n<li>\u6dfb\u52a0\u6269\u5c55\u5230\u4f60\u7684php.ini\u6587\u4ef6 extension=sm3.so<br \/>\n\u767b\u9646\u5b9d\u5854\u9762\u677f\uff0c\u627e\u5230PHP\u7248\u672c<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-597\" src=\"http:\/\/blog.yyhcw.com\/wp-content\/uploads\/2019\/07\/17\/blog.yyhcw.com_2019-07-17_16-38-44.jpg\" alt=\"\" width=\"504\" height=\"362\" \/><\/li>\n<li>\u6d4b\u8bd5\/usr\/local\/php\/bin\/php -r \"var_dump(sm3('abc'));\" \u8f93\u51fastring(64) \"66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0\"<\/li>\n<\/ol>\n<p>\u91cd\u542f\u4e0bphp\uff0c\u8fd9\u4e0b\u5c31\u597d\u4e86\uff0c\u53ef\u4ee5\u5728\u4f60\u7684\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u4e86\uff1a<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\nvar_dump(sm3('edxdf'));\r\n?&gt;<\/pre>\n<p>\u5230\u6b64\u7ed3\u675f\uff0c\u4ee5\u540e\u6709\u7c7b\u4f3c\u7684\u6269\u5c55\u90fd\u53ef\u4ee5\u8fd9\u6837\u5b89\u88c5\uff01\u4eca\u5929\u53c8\u4e0a\u4e86\u4e00\u8bfe\uff01<\/p>\n<h2><strong>\u91cd\u8981\u63d0\u793a\uff1a<\/strong><\/h2>\n<p>\u4e4b\u524d\u5b89\u88c5\u7684\u662f\u5728PHP7.2\u4e0a\u9762\u4e00\u5207\u90fd\u662f\u90a3\u4e48\u7684\u81ea\u7136\uff0c\u4eca\u5929\u5728PHP5.5\u4e0a\u9762\u5b89\u88c5\u5c31\u63d0\u793a\u9519\u8bef\u4e86\uff1a<\/p>\n<pre class=\"lang:python decode:true\">\/root\/php-sm3\/sm3.c: In function \u2018zif_confirm_sm3_compiled\u2019:\r\n\/root\/php-sm3\/sm3.c:457: error: \u2018zend_string\u2019 undeclared (first use in this function)\r\n\/root\/php-sm3\/sm3.c:457: error: (Each undeclared identifier is reported only once\r\n\/root\/php-sm3\/sm3.c:457: error: for each function it appears in.)\r\n\/root\/php-sm3\/sm3.c:457: error: \u2018strg\u2019 undeclared (first use in this function)\r\n\/root\/php-sm3\/sm3.c:499:30: error: macro \"RETURN_STRINGL\" requires 3 arguments, but only 2 given\r\n\/root\/php-sm3\/sm3.c: In function \u2018zif_sm3\u2019:\r\n\/root\/php-sm3\/sm3.c:499: error: \u2018RETURN_STRINGL\u2019 undeclared (first use in this function)\r\nmake: *** [sm3.lo] Error 1<\/pre>\n<p>\u6700\u7ec8\u53d1\u73b0\u53ea\u6709PHP&gt;=7.0\u624d\u53ef\u6b63\u5e38\u4f7f\u7528\uff0c\u5426\u5219\u51fa\u9519\uff01\u5982\u679c\u4f60\u5728\u4f4e\u4e8e7.0\u4e0a\u5b89\u88c5\u6210\u529f\u7684\u8bdd\uff0c\u9ebb\u70e6\u60a8\u544a\u8bc9\u6211\u4e0b\uff01\u6c42\u6559\uff0c\u8c22\u8c22\uff01<\/p>\n<!--wp-compress-html no compression--><!--wp-compress-html-->","protected":false},"excerpt":{"rendered":"\u8fd9\u51e0\u5929\u5bf9\u63a5\u4e2d\u56fd\u8054\u901a\u7269\u8054\u7f51IoT Gateway\u95e8\u6237API\u7cfb\u7edf\uff0c\u5176\u4e2d\u7528\u5230\u56fd\u5bc6SM3\uff0c\u5176\u63d0\u4f9b\u7684token\u9700\u4f7f\u7528\u56fd\u5bc6 \u00b7\u00b7\u00b7","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[135,134],"views":1957,"_links":{"self":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts\/596"}],"collection":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/comments?post=596"}],"version-history":[{"count":0,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts\/596\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/media?parent=596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/categories?post=596"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/tags?post=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}