イントロダクションIntroduction
LaravelのHash
ファサードは、保存するパスワードに安全なBcryptハッシュを提供します。Laravelアプリケーションに含まれている、AuthController
コントローラーを使用していれば、ユーザーから入力された、ハッシュされていないパスワードをBcryptされたパスワードと比較し確認することも面倒を見ます。The Laravel Hash
facade provides secure Bcrypt hashing for storing
user passwords. If you are using the
AuthController
controller that is
included with your Laravel application, it will be
take care of verifying the Bcrypt password against
the un-hashed version provided by the
user.
同様に、Laravelに初めから用意されているRegistrar
サービスは、保存するパスワードに対し、確実にbcrypt
関数を呼び出しハッシュ化します。Likewise, the user
Registrar
service that ships with
Laravel makes the proper bcrypt
function call to hash stored passwords.
基本的な使用法Basic Usage
Bcryptを使用しパスワードをハッシュHashing A Password Using Bcrypt
$password = Hash::make('secret');
bcryptヘルパも使用できます。You may also
use the bcrypt
helper
function:
$password = bcrypt('secret');
パスワードとハッシュ済み値の比較Verifying A Password Against A Hash
if (Hash::check('secret', $hashedPassword))
{
// パスワードが一致した…
}
パスワードの再ハッシュが必要か確認Checking If A Password Needs To Be Rehashed
if (Hash::needsRehash($hashed))
{
$hashed = Hash::make('secret');
}