CKTIS / PHP
password_hash()
Ustvari zgoščeno geslo s soljo, algoritmom in stroškom za preverjanje.
Različica: PHP 8.4; repository runtime, production runtime not attested
Sintaksa
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): stringUstvari zgoščeno geslo s soljo, algoritmom in stroškom za preverjanje. PHP sol ustvari sam. V PHP 8.4 se privzeti strošek bcrypt poveča na 12. bcrypt uporabi največ prvih 72 bajtov. Geslo preverite s password_verify(). V PHP 8.4 PASSWORD_DEFAULT izbere bcrypt. Poznejše različice lahko spremenijo algoritem in dolžino zgoščene vrednosti.
Podpis
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): string
Izhod primera
["bcrypt",12,true]
Primeri
<?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)]);
Rezultat
["bcrypt",12,true]