<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                * * * * * [TOC] ## 簡介 Laravel?`Hash`?[facade](http://www.hmoore.net/tonyyu/laravel_5_6/786058)?為存儲用戶密碼提供了安全的 Bcrypt 和 Argon2 哈希。如果您使用 Laravel 應用程序中內置的?`LoginController`?和?`RegisterController`?類,則默認情況下它們將使用 Bcrypt 進行注冊和身份驗證。 > {tip} Bcrypt 是哈希密碼的理想選擇,因為它的「加密系數」可以任意調整,這意味著生成哈希所需的時間可以隨著硬件功率的增加而增加。 ## 配置 您的應用程序的默認散列驅動程序在?`config/hashing.php`?配置文件中配置。目前有兩種支持的驅動程序:?[Bcrypt](https://en.wikipedia.org/wiki/Bcrypt)?和?[Argon2](https://en.wikipedia.org/wiki/Argon2)。 > {note} Argon2 驅動程序需要 PHP 7.2.0 或更高版本。 ## 基本用法 你可以通過調用?`Hash`?Facade 的?`make`?方法來填寫密碼: ~~~ <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; use App\Http\Controllers\Controller; class UpdatePasswordController extends Controller { /** * 更新用戶密碼。 * * @param Request $request * @return Response */ public function update(Request $request) { // 驗證新的密碼長度... $request->user()->fill([ 'password' => Hash::make($request->newPassword) ])->save(); } } ~~~ #### 調整 Bcrypt 加密系數 `make`?方法還能使用?`rounds`?選項來管理 bcrypt 哈希算法的加密系數。然而,大多數應用程序還是能接受默認值的: ~~~ $hashed = Hash::make('password', [ 'rounds' => 12 ]); ~~~ #### 調整 Argon2 加密系數 如果你使用 Argon2 算法,可以使用?`make`?方法中的?`memory`?,`time`?和?`threads`?選項來管理該算法的加密系數;然而,大多數應用都是可以接受默認值的: ~~~ $hashed = Hash::make('password', [ 'memory' => 1024, 'time' => 2, 'threads' => 2, ]); ~~~ > {tip} 有關這些選項的更多信息,請查閱?[PHP 官方文檔?](http://php.net/manual/en/function.password-hash.php). #### 密碼哈希驗證 `check`?方法能為你驗證一段給定的未加密字符串與給定的哈希串是否一致。然而, 如果你使用?`LoginController`?[Laravel 自帶的?](http://www.hmoore.net/tonyyu/laravel_5_6/786216)控制器,你可能不需要直接使用這個方法,因為該控制器會自動調用這個方法: ~~~ if (Hash::check('plain-text', $hashedPassword)) { // 密碼匹配 } ~~~ #### 檢驗密碼是否需要重新哈希 `needsRehash`?方法可以幫你確定當密碼被哈希時,被哈希計算器使用的加密系數是否發生變化: ~~~ if (Hash::needsRehash($hashed)) { $hashed = Hash::make('plain-text'); } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看