{"id":1508,"date":"2018-04-18T11:28:45","date_gmt":"2018-04-18T03:28:45","guid":{"rendered":"http:\/\/blog.hoyo.idv.tw\/?p=1508"},"modified":"2021-04-08T15:28:33","modified_gmt":"2021-04-08T07:28:33","slug":"php-%e5%96%ae%e5%90%91%e5%8a%a0%e5%af%86%ef%bc%8c%e6%9c%83%e5%93%a1%e8%b3%87%e6%96%99%e5%ba%ab%e5%af%86%e7%a2%bc%e5%ad%b8","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=1508","title":{"rendered":"PHP \u55ae\u5411\u52a0\u5bc6\uff0c\u6703\u54e1\u8cc7\u6599\u5eab\u5bc6\u78bc\u5b78"},"content":{"rendered":"<p>\u7576\u7db2\u7ad9\u9700\u8981\u6703\u54e1\u6a5f\u5236\u6642\uff0c\u9664\u4e86\u6703\u54e1\u540d\u7a31(\u59d3\u540d)\u3001\u5e33\u865f\u5916\uff0c\u7576\u7136\u6700\u91cd\u8981\u7684\u5c31\u662f\u5bc6\u78bc\u3002 \u5728\u6b64\u4e0d\u8a0e\u8ad6\u90a3\u4e9b\u8166\u6b98\u7684\u660e\u6587\u5bc6\u78bc<a href=\"http:\/\/plainpass.com\/\">http:\/\/plainpass.com\/<\/a> \u5bc6\u78bc\u52a0\u5bc6\u7684\u539f\u5247\u6709<\/p>\n<ol>\n<li>\u55ae\u5411\u52a0\u5bc6<\/li>\n<li>\u53ef\u4ee5\u6bd4\u5c0d\u6b63\u78ba\u8207\u5426<\/li>\n<\/ol>\n<p>\u4e00\u3001\u55ae\u5411\u52a0\u5bc6\uff1a\u4e5f\u5c31\u662f\u5c07\u5bc6\u78bc\u52a0\u5bc6\u5f8c\uff0c\u5f9e\u52a0\u5bc6\u8cc7\u8a0a\u7121\u6cd5\u9084\u539f\u6216\u5f97\u77e5\u539f\u59cb\u5bc6\u78bc\u5b57\u4e32\u3002\u9019\u662f\u5f8c\u7e8c\u8981\u8a0e\u8ad6\u7684\u6240\u4ee5\u5148\u8aaa\u660e\u96d9\u5411\u7de8\u78bc\u3002 <strong>\u96d9\u5411\u7de8\u78bc<\/strong>\u5c31\u662f\u53ef\u9084\u539f\u539f\u59cb\u8cc7\u6599\uff0c\u4f8b\u5982 base64<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\necho base64_encode( 'a' ); \/\/ \u5c07 a \u4f7f\u7528 base64 \u7de8\u78bc\uff0c\u7d50\u679c\u70ba YQ==\r\necho base64_decode( 'YQ==' ); \/\/ \u5c07 YQ== \u4f7f\u7528 base64 \u89e3\u78bc\uff0c\u7d50\u679c\u70ba a<\/pre>\n<p>\u81f3\u65bc\u55ae\u5411\u52a0\u5bc6\u53ef\u4ee5\u4f7f\u7528 md5() \u6216\u662f sha1 \uff0c\u4f8b\u5982<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\necho md5( 'a' ); \/\/ 0cc175b9c0f1b6a831c399e269772661\r\necho sha1( 'a' ); \/\/ 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8\r\n<\/pre>\n<ul>\n<li>md5() \u55ae\u5411\u300c\u56fa\u5b9a\u300d\u52a0\u5bc6\uff0c\u5b57\u5143\u9577\u5ea6 32<\/li>\n<li>sha1() \u55ae\u5411\u300c\u56fa\u5b9a\u300d\u52a0\u5bc6\uff0c\u5b57\u5143\u9577\u5ea6 40<\/li>\n<\/ul>\n<p>\u4ec0\u9ebc\u662f\u56fa\u5b9a\u52a0\u5bc6\uff1f\u9867\u540d\u601d\u7fa9\u5c31\u662f\u6bcf\u6b21\u52a0\u5bc6\u7684\u7d50\u679c\u662f\u4e00\u6a23\u7684\uff0c\u4e5f\u5c31\u662f\u5982\u6b64\u7684\u7279\u6027\u624d\u53ef\u4ee5\u62ff\u4f86\u7576\u4f5c\u5bc6\u78bc\u6bd4\u5c0d\u3002<\/p>\n<p>--<\/p>\n<h2>\u8b8a\u52d5\u7684\u52a0\u5bc6\u5b57\u4e32<\/h2>\n<ul>\n<li><a href=\"http:\/\/php.net\/manual\/zh\/function.crypt.php\" target=\"_blank\" rel=\"noopener\">PHP: crypt - Manual<\/a><\/li>\n<\/ul>\n<p>\u90a3\u6709\u8b8a\u52d5\u52a0\u5bc6\u55ce\uff1f\u5728 PHP \u88e1\u4e5f\u662f\u6709\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528 crypt()<\/p>\n<p>\u7522\u751f\u52a0\u5bc6\uff0c\u4ee5 <strong>sha256<\/strong> \u70ba\u4f8b<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\necho crypt('abc', '$5$rounds=5000$'. uniqid() .'$');<\/pre>\n<p>\u7576\u4e0b\u7522\u751f\u7684\u52a0\u5bc6\u5b57\u4e32\u70ba<\/p>\n<pre class=\"lang:default decode:true\">$5$rounds=5000$5ad2b33017c4e$jztEpFXSNd53ndl.i0bif5vNGbOTIaZVBKb.aqWy\/x6<\/pre>\n<p>\u4f7f\u7528 uniqid() \u7684\u7de3\u6545\uff0c\u6240\u4ee5\u91cd\u65b0\u6574\u7406\u6bcf\u6b21\u7522\u751f\u7684\u5b57\u4e32\u7686\u4e0d\u540c\uff0c\u5982\u6b64\u5373\u53ef\u9632\u6b62\u5169\u500b\u76f8\u540c\u7684\u5bc6\u78bc\u88ab\u8f15\u6613\u7834\u89e3<\/p>\n<p>\u67e5\u6838\u5bc6\u78bc\u6642\uff0c\u56e0\u70ba\u5b57\u4e32\u8b8a\u52d5\u7684\u7de3\u6545\u7121\u6cd5\u55ae\u7d14\u7684\u4f7f\u7528\u5b57\u4e32\u6bd4\u5c0d\u7684\u65b9\u5f0f\uff0c\u9084\u662f\u9700\u8981\u4f7f\u7528 crypt() function \u4f86\u6aa2\u67e5<\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n$hashed_password = '$5$rounds=5000$5ad2b33017c4e$jztEpFXSNd53ndl.i0bif5vNGbOTIaZVBKb.aqWy\/x6';\r\nif (crypt('abc', $hashed_password) == $hashed_password) {\r\n    echo '\u5bc6\u78bc\u543b\u5408\uff01';\r\n}<\/pre>\n<p><strong>\u6848\u4f8b\u4e8c\uff1a\u4e00\u500b\u76f8\u5c0d\u7cbe\u7c21\u7684\u6848\u4f8b<\/strong><\/p>\n<pre class=\"lang:php decode:true\">&lt;?php\r\n$a = crypt('hoyo', '');\r\nif (crypt('hoyo', '$1$mGxOBjJX$7ofXUMIKBGs0Lv1sQ76Kw\/') == '$1$mGxOBjJX$7ofXUMIKBGs0Lv1sQ76Kw\/'){\r\n    echo 'Hoyo!!!';\r\n}<\/pre>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"1508\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,903&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7576\u7db2\u7ad9\u9700\u8981\u6703\u54e1\u6a5f\u5236\u6642\uff0c\u9664\u4e86\u6703\u54e1...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"1508\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,903&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[260],"tags":[146,144,141,53,142,143,145],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1508"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1508"}],"version-history":[{"count":28,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1508\/revisions"}],"predecessor-version":[{"id":8109,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1508\/revisions\/8109"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}