CKTIS / PHP
password_hash()
Produit un hachage de mot de passe avec sel, algorithme et coût pour la vérification.
Version : PHP 8.4; repository runtime, production runtime not attested
Syntaxe
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): stringProduit un hachage de mot de passe avec sel, algorithme et coût pour la vérification. PHP génère le sel automatiquement. En PHP 8.4 le coût bcrypt par défaut passe à 12. bcrypt utilise au plus les 72 premiers octets. Vérifiez avec password_verify(). En PHP 8.4 PASSWORD_DEFAULT choisit bcrypt. L’algorithme et la longueur du hachage peuvent changer à l’avenir.
Signature
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): string
Sortie de l’exemple
["bcrypt",12,true]
Exemples
<?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)]);
Résultat
["bcrypt",12,true]