및 [중복] 죄송합니다. 하루를 보내고 해결책을 찾지 못했습니다. PDO 준비 문에 PHP 암호문 유효성 검사 오류
function generateHash($password, $round=10){
$salt=substr(base64_encode(openssl_random_pseudo_bytes(17)),0,22);
$salt=str_replace("+",".",$salt);
$param='$'.implode('$',array(
"2y",
str_pad($round,2,"0",STR_PAD_LEFT),
$salt
)
);
return crypt($password,$param);
}
//NOW I INSERT HASH TO DB
$input = "abc";
$hashed = generateHash($input);
$createAccount=$db->prepare("INSERT INTO account ....
':secret' => $hashed;
.....)); // Until here, no problem, $hashed can be inserted correctely into my db (password, Varchar (64)
지금 등록 후, 사용자가 여기에 로그인을 좋아하는 문제이다 : 여기, 토굴
(검증)에 문제가 있어요 나의 코드입니다. 내가 잘 기능
$input = "abc";
$forCheck = "abc";
$hashedHash = generateHash($input);
if (crypt($forCheck, $hashedHash) == $hashedHash) {
echo "MATCH";
}else {
echo "NOT MATCH";
}
// OUTPUT: "MATCH"
문제했다면 우선, 내가 여기에,보고, 점검을 해요 :
$check=$db->prepare("SELECT id, password FROM account WHERE email = :email ");
$check->execute(array(
':email' => $user
)
);
if ($check->rowCount() <= 0) {
echo "You are not registered";
}else {
$sRow=$check->fetchAll(PDO::FETCH_ASSOC);
foreach ($sRow as $row) {
$hashedHash = generateHash($row['password']);
if (crypt($input, $hashedHash) == $hashedHash) {
echo "Passwords Matched";
}else {
echo "Passwords did not match";
}
}
}
// OUTPUT: "Passwords did not match"
어떤 도움을 주 시겠어요? 문제는 여기에있다
첫 번째 코드 블록 (INSERT 비트)에서'createHash'가'generateHash'가되어야합니까? – Phil
나는 생각한다 ** generateHash ** – user3281766