private static function generateSalt (int $length) : string
	{
		// Not 100% unique, not 100% random, but good enough for a salt
		// MD5 returns 32 characters
		$uniqueRandomString = md5(uniqid(mt_rand(),true));

		// Valid Characters for a salt are [a-AZ-Z0-9./]
		$base64String = base64_encode($uniqueRandomString);

		// But no '+' which is valid in base64 encoding
		$modifiedBase64String = str_replace('+', '.', $base64String);

		// Truncate String to the correct length
		return substr($modifiedBase64String, 0, $length);
	}
private static function generateSalt (int $length) : string
	{
		// Not 100% unique, not 100% random, but good enough for a salt
		// MD5 returns 32 characters
		$uniqueRandomString = md5(uniqid(mt_rand(),true));

		// Valid Characters for a salt are [a-AZ-Z0-9./]
		$base64String = base64_encode($uniqueRandomString);

		// But no '+' which is valid in base64 encoding
		$modifiedBase64String = str_replace('+', '.', $base64String);

		// Truncate String to the correct length
		return substr($modifiedBase64String, 0, $length);
	}
private static function generateSalt ( int $ length ) : string { // Not 100% unique, not 100% random, but good enough for a salt // MD5 returns 32 characters $ uniqueRandomString = md5 ( uniqid ( mt_rand ( ) , true ) ) ; // Valid Characters for a salt are [a-AZ-Z0-9./] $ base64String = base64_encode ( $ uniqueRandomString ) ; // But no '+' which is valid in base64 encoding $ modifiedBase64String = str_replace ( '+' , '.' , $ base64String ) ; // Truncate String to the correct length return substr ( $ modifiedBase64String , 0 , $ length ) ; }
Generates salt for hashing.
@param int $length
@return string
Generates salt for hashing .