CKTIS / PHP
password_hash()
Erstellt einen gesalzenen Passworthash samt Algorithmuskennung und Kosten für die spätere Prüfung.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): stringErstellt einen gesalzenen Passworthash samt Algorithmuskennung und Kosten für die spätere Prüfung. PHP erzeugt das Salz selbst. In PHP 8.4 beträgt der Standardaufwand für bcrypt 12. bcrypt nutzt höchstens die ersten 72 Bytes. Zur Prüfung dient password_verify(). PASSWORD_DEFAULT wählt in PHP 8.4 bcrypt. Spätere Versionen können Algorithmus und Hashlänge ändern.
Signatur
password_hash(#[SensitiveParameter] string $password, string|int|null $algo, array $options = []): string
Ausgabe des Beispiels
["bcrypt",12,true]
Beispiele
<?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)]);
Ergebnis
["bcrypt",12,true]