lithium\security\Password::_generateSaltXdes()

protected static method

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 be 1 to 24. 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

string

The 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;
	}