{"id":96628,"date":"2024-10-20T11:02:17","date_gmt":"2024-10-20T03:02:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/96628\/"},"modified":"2024-10-20T11:02:18","modified_gmt":"2024-10-20T03:02:18","slug":"php%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e4%bf%9d%e9%9a%9c%e6%95%b8%e6%93%9a%e5%ae%89%e5%85%a8-php%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ae%89%e5%85%a8%e5%8a%a0%e5%af%86","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/96628\/","title":{"rendered":"php\u6578\u64da\u5eab\u52a0\u5bc6\u4fdd\u969c\u6578\u64da\u5b89\u5168 (php\u6578\u64da\u5eab\u5b89\u5168\u52a0\u5bc6)"},"content":{"rendered":"<h1 id=\"php%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e4%bf%9d%e9%9a%9c%e6%95%b8%e6%93%9a%e5%ae%89%e5%85%a8-uXvnBBhPRe\">PHP\u6578\u64da\u5eab\u52a0\u5bc6\u4fdd\u969c\u6578\u64da\u5b89\u5168<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u5b57\u5316\u7684\u6642\u4ee3\uff0c\u6578\u64da\u5b89\u5168\u5df2\u6210\u70ba\u4f01\u696d\u548c\u500b\u4eba\u7528\u6236\u6700\u95dc\u6ce8\u7684\u554f\u984c\u4e4b\u4e00\u3002\u96a8\u8457\u7db2\u7d61\u653b\u64ca\u548c\u6578\u64da\u6d29\u9732\u4e8b\u4ef6\u7684\u983b\u7e41\u767c\u751f\uff0c\u5982\u4f55\u6709\u6548\u5730\u4fdd\u8b77\u6578\u64da\u6210\u70ba\u4e86\u6bcf\u500b\u958b\u767c\u8005\u548c\u7cfb\u7d71\u7ba1\u7406\u54e1\u7684\u9996\u8981\u4efb\u52d9\u3002PHP\u4f5c\u70ba\u4e00\u7a2e\u6d41\u884c\u7684\u7db2\u9801\u958b\u767c\u8a9e\u8a00\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u65b9\u6cd5\u4f86\u52a0\u5bc6\u6578\u64da\u5eab\u4e2d\u7684\u654f\u611f\u4fe1\u606f\uff0c\u5f9e\u800c\u4fdd\u969c\u6578\u64da\u7684\u5b89\u5168\u6027\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%9c%80%e8%a6%81%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%ef%bc%9f-uXvnBBhPRe\">\u70ba\u4ec0\u9ebc\u9700\u8981\u6578\u64da\u5eab\u52a0\u5bc6\uff1f<\/h2>\n<p>\u6578\u64da\u5eab\u52a0\u5bc6\u7684\u4e3b\u8981\u76ee\u7684\u662f\u4fdd\u8b77\u5b58\u5132\u5728\u6578\u64da\u5eab\u4e2d\u7684\u654f\u611f\u4fe1\u606f\uff0c\u4f8b\u5982\u7528\u6236\u7684\u500b\u4eba\u8cc7\u6599\u3001\u5bc6\u78bc\u548c\u91d1\u878d\u4fe1\u606f\u3002\u672a\u7d93\u52a0\u5bc6\u7684\u6578\u64da\u5728\u6578\u64da\u6d29\u9732\u6642\u53ef\u80fd\u6703\u88ab\u9ed1\u5ba2\u8f15\u6613\u7372\u53d6\uff0c\u9020\u6210\u56b4\u91cd\u7684\u5f8c\u679c\u3002\u901a\u904e\u52a0\u5bc6\uff0c\u6578\u64da\u5373\u4f7f\u88ab\u76dc\u53d6\uff0c\u4e5f\u7121\u6cd5\u88ab\u672a\u7d93\u6388\u6b0a\u7684\u7528\u6236\u89e3\u8b80\u3002<\/p>\n<h2 id=\"php%e4%b8%ad%e7%9a%84%e6%95%b8%e6%93%9a%e5%8a%a0%e5%af%86%e6%96%b9%e6%b3%95-uXvnBBhPRe\">PHP\u4e2d\u7684\u6578\u64da\u52a0\u5bc6\u65b9\u6cd5<\/h2>\n<p>\u5728PHP\u4e2d\uff0c\u6709\u591a\u7a2e\u52a0\u5bc6\u6280\u8853\u53ef\u4ee5\u7528\u4f86\u4fdd\u8b77\u6578\u64da\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8openssl%e9%80%b2%e8%a1%8c%e5%8a%a0%e5%af%86-uXvnBBhPRe\">1. \u4f7f\u7528OpenSSL\u9032\u884c\u52a0\u5bc6<\/h3>\n<p>OpenSSL\u662f\u4e00\u500b\u5f37\u5927\u7684\u52a0\u5bc6\u5eab\uff0cPHP\u63d0\u4f9b\u4e86\u5c0d\u5176\u7684\u652f\u6301\u3002\u4f7f\u7528OpenSSL\u53ef\u4ee5\u8f15\u9b06\u5730\u5c0d\u6578\u64da\u9032\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>\n\n<\/code><\/pre>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8hash%e5%87%bd%e6%95%b8%e5%ad%98%e5%84%b2%e5%af%86%e7%a2%bc-uXvnBBhPRe\">2. \u4f7f\u7528Hash\u51fd\u6578\u5b58\u5132\u5bc6\u78bc<\/h3>\n<p>\u5c0d\u65bc\u7528\u6236\u5bc6\u78bc\uff0c\u5efa\u8b70\u4f7f\u7528\u54c8\u5e0c\u51fd\u6578\u9032\u884c\u8655\u7406\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u5b58\u5132\u660e\u6587\u5bc6\u78bc\u3002PHP\u63d0\u4f9b\u4e86password_hash()\u548cpassword_verify()\u51fd\u6578\u4f86\u7c21\u5316\u9019\u4e00\u904e\u7a0b\uff1a<\/p>\n<pre><code>\n\n<\/code><\/pre>\n<h3 id=\"3-%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b1%a4%e7%b4%9a%e7%9a%84%e5%8a%a0%e5%af%86-uXvnBBhPRe\">3. \u6578\u64da\u5eab\u5c64\u7d1a\u7684\u52a0\u5bc6<\/h3>\n<p>\u9664\u4e86\u5728\u61c9\u7528\u5c64\u9032\u884c\u52a0\u5bc6\uff0c\u9084\u53ef\u4ee5\u8003\u616e\u5728\u6578\u64da\u5eab\u5c64\u9032\u884c\u52a0\u5bc6\u3002\u8a31\u591a\u73fe\u4ee3\u6578\u64da\u5eab\u7cfb\u7d71\uff08\u5982MySQL\u548cPostgreSQL\uff09\u90fd\u63d0\u4f9b\u4e86\u5167\u5efa\u7684\u52a0\u5bc6\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u6578\u64da\u5beb\u5165\u6578\u64da\u5eab\u4e4b\u524d\u9032\u884c\u52a0\u5bc6\uff0c\u9019\u6a23\u5373\u4f7f\u6578\u64da\u5eab\u88ab\u653b\u64ca\uff0c\u6578\u64da\u4e5f\u6703\u4fdd\u6301\u5b89\u5168\u3002<\/p>\n<h2 id=\"%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-uXvnBBhPRe\">\u6700\u4f73\u5be6\u8e10<\/h2>\n<ul>\n<li>\u5b9a\u671f\u66f4\u65b0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u4f7f\u7528\u6700\u65b0\u7684\u5b89\u5168\u6a19\u6e96\u3002<\/li>\n<li>\u59a5\u5584\u7ba1\u7406\u5bc6\u9470\uff0c\u907f\u514d\u5c07\u5bc6\u9470\u786c\u7de8\u78bc\u5728\u4ee3\u78bc\u4e2d\u3002<\/li>\n<li>\u5c0d\u654f\u611f\u6578\u64da\u9032\u884c\u6700\u5c0f\u5316\u5b58\u5132\uff0c\u50c5\u4fdd\u7559\u5fc5\u8981\u7684\u4fe1\u606f\u3002<\/li>\n<li>\u5b9a\u671f\u9032\u884c\u5b89\u5168\u5be9\u8a08\uff0c\u6aa2\u67e5\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-uXvnBBhPRe\">\u7d50\u8ad6<\/h2>\n<p>\u6578\u64da\u5eab\u52a0\u5bc6\u662f\u4fdd\u969c\u6578\u64da\u5b89\u5168\u7684\u91cd\u8981\u624b\u6bb5\u3002\u901a\u904e\u4f7f\u7528PHP\u4e2d\u7684\u5404\u7a2e\u52a0\u5bc6\u6280\u8853\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u6709\u6548\u5730\u4fdd\u8b77\u7528\u6236\u7684\u654f\u611f\u4fe1\u606f\uff0c\u964d\u4f4e\u6578\u64da\u6d29\u9732\u7684\u98a8\u96aa\u3002\u96a8\u8457\u6280\u8853\u7684\u767c\u5c55\uff0c\u6301\u7e8c\u95dc\u6ce8\u548c\u66f4\u65b0\u5b89\u5168\u63aa\u65bd\u5c07\u662f\u6bcf\u500b\u958b\u767c\u8005\u7684\u8cac\u4efb\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u6578\u64da\u5b89\u5168\u548c\u76f8\u95dc\u6280\u8853\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u6211\u5011\u63d0\u4f9b\u5404\u7a2e <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u60a8\u4fdd\u969c\u6578\u64da\u5b89\u5168\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22PHP\u6578\u64da\u5eab\u52a0\u5bc6\u6280\u8853\uff0c\u4fdd\u969c\u6578\u64da\u5b89\u5168\uff0c\u9632\u6b62\u672a\u6388\u6b0a\u8a2a\u554f\uff0c\u78ba\u4fdd\u654f\u611f\u4fe1\u606f\u7684\u5b89\u5168\u5b58\u5132\u8207\u50b3\u8f38\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-96628","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=96628"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96628\/revisions"}],"predecessor-version":[{"id":96629,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96628\/revisions\/96629"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=96628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=96628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=96628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}