イントロダクションIntroduction
LaravelのHashファサードは保存するパスワードに安全なBcryptハッシュを提供します。Laravelアプリケーションに含まれているAuthControllerコントローラーを使用していれば、ユーザーから入力されたハッシュされていないパスワードをBcryptされたパスワードと比較し確認する面倒を見てくれます。The Laravel Hash facade[/docs/{{version}}/facades] provides secure Bcrypt hashing for storing user passwords. If you are using the AuthController controller that is included with your Laravel application, it will automatically use Bcrypt for registration and authentication.
Bcryptは「ストレッチ回数」が調整できるのでパスワードのハッシュには良い選択肢です。つまりハードウェアのパワーを上げればハッシュの生成時間を早くすることができます。Bcrypt is a great choice for hashing passwords because its "work factor" is adjustable, which means that the time it takes to generate a hash can be increased as hardware power increases.
基本的な使用法Basic Usage
Hashファサードのmakeメソッドを呼び出し、パスワードをハッシュできます。You may hash a password by calling the make method on the Hash facade:
<?php
namespace App\Http\Controllers;
use Hash;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
    /**
     * ユーザーパスワードを更新
     *
     * @param  Request  $request
     * @param  int  $id
     * @return Response
     */
    public function updatePassword(Request $request, $id)
    {
        $user = User::findOrFail($id);
        // 新しいパスワードの長さのバリデーション…
        $user->fill([
            'password' => Hash::make($request->newPassword)
        ])->save();
    }
}
別の方法として、bcryptヘルパ関数を使うこともできます。Alternatively, you may also use the global bcrypt helper function:
bcrypt('平文');
パスワードとハッシュ値の比較Verifying A Password Against A Hash
checkメソッドにより指定した平文文字列と指定されたハッシュ値を比較確認できます。しかしLaravelに含まれているAuthControllerを使っている場合は、認証コントローラーがこのメソッドを自動的に呼び出します。The check method allows you to verify that a given plain-text string corresponds to a given hash. However, if you are using the AuthController included with Laravel[/docs/{{version}}/authentication], you will probably not need to use this directly, as the included authentication controller automatically calls this method:
if (Hash::check('平文', $hashedPassword)) {
    // パスワード一致…
}
パスワードの再ハッシュが必要か確認Checking If A Password Needs To Be Rehashed
パスワードがハシュされてからハッシャーのストレッチ回数が変更されているかを調べるには、needsRehashメソッドを使います。The needsRehash function allows you to determine if the work factor used by the hasher has changed since the password was hashed:
if (Hash::needsRehash($hashed)) {
    $hashed = Hash::make('平文');
}