CKTIS / PHP
password_hash()
Vytvorí odtlačok hesla so soľou, algoritmom a cenou pre overenie.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): stringVytvorí odtlačok hesla so soľou, algoritmom a cenou pre overenie. PHP soľ vytvára automaticky. V PHP 8.4 sa predvolená cena bcrypt zvýšila na 12. bcrypt použije najviac prvých 72 bajtov. Heslo overte pomocou password_verify(). V PHP 8.4 volí PASSWORD_DEFAULT bcrypt. Budúce verzie môžu zmeniť algoritmus aj dĺžku odtlačku.
Signatúra
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): string
Výstup príkladu
["bcrypt",12,true]
Príklady
<?php
$hash=password_hash("maple notes",PASSWORD_DEFAULT);
echo json_encode([password_get_info($hash)["algoName"],password_get_info($hash)["options"]["cost"],password_verify("maple notes",$hash)]);
Výsledok
["bcrypt",12,true]