« Xpass 関数
crypt_gensalt »

crypt_checksalt

(PECL xpass >= 1.1.0)

crypt_checksalt — Validate a crypt setting string

説明

function 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 one of the CRYPT_SALT_* as an int.

例

例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)

参考

関連キーワード:
crypt   salt   checksalt   gensalt   method   Validate   setting   Xpass   whether   hashing   Generate   Check   dump   xpass   Checks   against   system   configuration   reports   parameters   specifies   acceptable   intended   used   determine
関連する関数・ページ:
ref.xpass   function.crypt-gensalt   book.xpass   function.crypt   function.crypt-preferred-method   strings.installation