{"id":176,"date":"2023-02-19T19:13:51","date_gmt":"2023-02-19T11:13:51","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=176"},"modified":"2023-02-19T19:14:58","modified_gmt":"2023-02-19T11:14:58","slug":"laravel-bcrypt-encrypt-store-verify-password","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/19\/laravel-bcrypt-encrypt-store-verify-password\/","title":{"rendered":"Laravel\u4f7f\u7528Bcrypt\u52a0\u5bc6\u65b9\u5f0f\u5b58\u50a8\u53ca\u6821\u9a8c\u5bc6\u7801"},"content":{"rendered":"<p>Laravel\u4f7f\u7528Bcrypt\u52a0\u5bc6\u65b9\u5f0f\u5b58\u50a8\u53ca\u6821\u9a8c\u5bc6\u7801\uff1a<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-php\">\/\/\u5bf9 A \u5bc6\u7801\u4f7f\u7528 bcrypt \u52a0\u5bc6\n$password = Hash::make(&#039;secret&#039;);\n\n\/\/\u4e5f\u53ef\u76f4\u63a5\u4f7f\u7528 bcrypt \u7684 function\n$password = bcrypt(&#039;secret&#039;);\n\n\/\/\u5bf9\u52a0\u5bc6\u7684 A \u5bc6\u7801\u8fdb\u884c\u9a8c\u8bc1\nif (Hash::check(&#039;secret&#039;, $hashedPassword)) {\n    \/\/ The passwords match...\n}\n\/\/\u68c0\u67e5 A \u5bc6\u7801\u662f\u5426\u9700\u8981\u91cd\u65b0\u52a0\u5bc6\nif (Hash::needsRehash($hashed)) {\n    $hashed = Hash::make(&#039;secret&#039;);\n}<\/code><\/pre>\n<p>\u76ee\u524d\u5e38\u7528\u7684\u4e0d\u53ef\u9006\u52a0\u5bc6\u7b97\u6cd5\uff1a<\/p>\n<ul>\n<li>MD5\u53ca\u52a0\u76d0<\/li>\n<li>SHA\u53ca\u52a0\u76d0<\/li>\n<li>PBKDF2\u7b97\u6cd5<\/li>\n<li>bcrypt<\/li>\n<\/ul>\n<p>\u901a\u5e38\u63a8\u8350\u4f7f\u7528 bcrypt \u6216 PBKDF2 \u8fd9\u4e24\u79cd\u7b97\u6cd5\u6765\u5bf9\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\uff0cbcrypt\u4e0d\u652f\u6301\u8d85\u8fc755\u4e2a\u5b57\u7b26\u7684\u5bc6\u7801\u77ed\u8bed\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u4f7f\u7528Bcrypt\u52a0\u5bc6\u65b9\u5f0f\u5b58\u50a8\u53ca\u6821\u9a8c\u5bc6\u7801\uff1a \/\/\u5bf9 A \u5bc6\u7801\u4f7f\u7528 bcrypt \u52a0\u5bc6 $passw [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[72],"class_list":["post-176","post","type-post","status-publish","format-standard","hentry","category-laravel","tag-laravel"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}