CKTIS / PHP
password_hash()
Genera un hash della password con sale, algoritmo e costo per la verifica.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): stringGenera un hash della password con sale, algoritmo e costo per la verifica. PHP crea automaticamente il sale. In PHP 8.4 il costo bcrypt predefinito sale a 12. bcrypt considera al massimo i primi 72 byte. Per la verifica usare password_verify(). In PHP 8.4 PASSWORD_DEFAULT sceglie bcrypt. Versioni future possono cambiare algoritmo e lunghezza dell’hash.
Firma
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): string
Output dell’esempio
["bcrypt",12,true]
Esempi
<?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)]);
Risultato
["bcrypt",12,true]