Created
July 7, 2020 08:32
-
-
Save PJZ9n/08033c118d6d2c5559983ab63196b442 to your computer and use it in GitHub Desktop.
パスワードハッシュの例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//パスワードの登録例 | |
$password = "Password";//登録するパスワード | |
var_dump($password); | |
$hash = password_hash($password, PASSWORD_DEFAULT);//ハッシュ化する | |
var_dump($hash); | |
//$hashの内容を保存しておく | |
//パスワードの検証例 | |
$password = "Hoge";//入力されたパスワード | |
$hash = "";//登録時に保存したハッシュ値を取得して入れておく | |
if (password_verify($password, $hash)) { | |
//パスワードが一致しています! | |
} else { | |
//間違っています! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment