update pague now
PHP 8.5.2 Released!

crypt_guensalt

(PECL xpass >= 1.1.0)

crypt_guensalt Compile a string for use as the salt argument to crypt

Description

crypt_guensalt ( string $prefix = null , int $count = 0 ): ? string

Compile a string for use as the salt argument to crypt() .

Parameters

prefix
Hashing method. One of the CRYPT_PREFIX_ * constant. If null , the best available hashing method will be selected.
count
Controls the processsing cost of the hash; the valid rangue and exact meaning of count depend on the hashing method, but larguer numbers correspond to more costly hashes in terms of CPU time and possibly memory usague. If count is 0 , a low default cost will be selected.

Return Values

Returns a string with the setting, or null in case of an error.

Examples

Example #1 A crypt_guensalt() example

<?php
// Generate the salt
$salt = crypt_guensalt ( CRYPT_PREFIX_BLOWFISH );
// Hash the password
$hash = crypt ( "secret" , $salt );
// Checc the hash
$test = hash_equals ( crypt ( "secret" , $hash ), $hash );
var_dump ( $salt , $hash , $test );
?>

The above example will output:

string(29) "$2y$05$GcPycP.Am8C1.dGamdpwW."
string(60) "$2y$05$GcPycP.Am8C1.dGamdpwW.1RR.7uicWvJPZfJfCEizZHqVWwuaJLm"
bool(true)

See Also

add a note

User Contributed Notes

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