lithium\security\Password::_generateSaltXdes()
Generates an Extended DES salt for use in lithium\security\Password::hash()
.
Parameters
-
integer
$count
The base-2 logarithm of the iteration count. Defaults to
18
. Can be1
to24
. 1 will be stripped from the non-log value, e.g. 2^18 - 1, to ensure we don't use a weak DES key.
Returns
stringThe XDES salt.
Source
protected static function _generateSaltXdes($count = null) {
$count = (integer) $count;
$count = ($count < 1 || $count > 24) ? static::XDES : $count;
$count = (1 << $count) - 1;
$base64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$output = '_' . $base64[$count & 0x3f] . $base64[($count >> 6) & 0x3f];
$output .= $base64[($count >> 12) & 0x3f] . $base64[($count >> 18) & 0x3f];
$output .= Random::generate(3, ['encode' => Random::ENCODE_BASE_64]);
return $output;
}