International PHP Conference Berlin 2025

crypt_checksalt

(PECL xpass >= 1.1.0)

crypt_checksaltValidate a crypt setting string

Опис

crypt_checksalt(string $salt): ?string

Checks the salt string against the system configuration and reports whether the hashing method and parameters it specifies are acceptable. It is intended to be used to determine whether the user's passphrase should be re-hashed using the currently preferred hashing method.

Параметри

salt

Salt string to check.

Значення, що повертаються

Returns an int, one of CRYPT_SALT_* constant, see the Xpass constants page.

Приклади

Приклад #1 A crypt_checksalt() example

<?php
// Generate a salt for a legacy method
$salt = crypt_gensalt(CRYPT_PREFIX_STD_DES);
// Check the salt
$test = crypt_checksalt($salt);
var_dump($test === CRYPT_SALT_METHOD_LEGACY);

// Generate a salt for default method
$salt = crypt_gensalt();
// Check the salt
$test = crypt_checksalt($salt);
var_dump($test === CRYPT_SALT_OK);
?>

Поданий вище приклад виведе:

bool(true)
bool(true)

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top