Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

password_verify()

Check a candidate password against the stored encoded hash.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

password_verify(#[SensitiveParameter] string $password, string $hash): bool

Check a candidate password against the stored encoded hash. The hash carries the salt, cost and algorithm, so verification requires no separate salt. The timing-safe check returns false for a mismatch. For bcrypt, the 72-byte password limit also applies during verification.

Signature

password_verify(#[SensitiveParameter] string $password, string $hash): bool

Example output

[true,false]

Examples

<?php
$hash=password_hash("Maple notes",PASSWORD_BCRYPT);
echo json_encode([password_verify("Maple notes",$hash),password_verify("maple notes",$hash)]);

Result

[true,false]

Sources