Generates salt. If openssl_random_pseudo_bytes function is not available,
than fallback to custom salt generator.

@return string
320322
public function generate()
    {
        if ($this->_getOpenSSLFunctionalityChecker()->isOpenSslRandomBytesGeneratorAvailable()) {
            $sSalt = bin2hex(openssl_random_pseudo_bytes(16));
        } else {
            $sSalt = $this->_customSaltGenerator();
        }

        return $sSalt;
    }
599408
protected function createSalt()
    {
        $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./';
        $max = strlen($pool) - 1;
        $salt = '';
        for ($i = 0; $i < $this->saltLength; ++$i) {
            $salt .= $pool[random_int(0, $max)];
        }
        return $salt;
    }
317078
public static function generateHash($password) {
        // A higher "cost" is more secure but consumes more processing power
        $cost = 10;

        // Create a random salt
        $salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');

        // Prefix information about the hash so PHP knows how to verify it later.
        // "$2a$" Means we're using the Blowfish algorithm. The following two digits are the cost parameter.
        $salt = sprintf("$2a$%02d$", $cost) . $salt;

        // Value:
        // $2a$10$eImiTXuWVxfM37uY4JANjQ==
        // Hash the password with the salt
        $hash = crypt($password, $salt);

        return $hash;
    }
896525
public static function getSalt(): string
    {
        $result = '';

        try {
            $result = static::readSaltFromFile();
        } catch (InvalidArgumentException $e) {
            Log::warning("Failed to read salt from file");
        }

        if ($result) {
            return $result;
        }

        try {
            $salt = static::generateSalt();
            static::writeSaltToFile($salt);
            $result = static::readSaltFromFile();
        } catch (InvalidArgumentException $e) {
            throw new InvalidArgumentException("Failed to regenerate and save new salt: " . $e->getMessage(), 0, $e);
        }
        Log::warning("New salt is generated and stored.  Users might need to logout and clean their cookies.");

        return $result;
    }
1202593
public function genSalt($input = null)
    {
        if (!$input) {
            $input = $this->_getRandomBytes(12);
        }

        $identifier = $this->_identifier;

        $rounds = '';
        if ($this->_iterationCount != 5000) {
            $rounds = 'rounds=' . $this->_iterationCount . '$';
        }

        $salt = $this->_encode64($input, 12);

        return '$' . $identifier . '$' . $rounds . $salt . '$';
    }
722996
protected function generateToken()
	{
		if (function_exists('openssl_random_pseudo_bytes'))
		{
			$token = base64_encode( openssl_random_pseudo_bytes(32));
		}
		elseif (function_exists("hash_algos") and in_array("sha256",hash_algos()))
		{
			// generate a random token using sha256
			$token = hash("sha256",mt_rand(0,mt_getrandmax()));
		}
		else
		{
			// use a randomizer algorithm if we don't have hash-sha256 available
			$token='';
			for ($i=0;$i<64;++$i)
			{
				$r=mt_rand(0,35);
				$token .= $r<26 ? chr(ord('a')+$r) : chr(ord('0')+$r-26);
			}
		}

		return $token;
	}
1023178
public function salt($password, $member = null)
    {
        $generator = new RandomGenerator();
        return sprintf('%02d', self::$cost) . '$' . substr($generator->randomToken('sha1'), 0, 22);
    }
1310711
protected function _createSalt($length = 32)
    {
        static $chars ='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM01234567890';

        $max  = strlen($chars) - 1;
        $salt = '';

        for ($i = 0; $i < $length; ++$i) {
            $salt .= $chars[(mt_rand(0, $max))];
        }

        return $salt;
    }
1016423
protected function _generateUUID()
    {
        $data = null;
        switch (true) {
            case $this->_isCallable('random_bytes'):
                $data = $this->_randomBytes(16);
                break;
            case $this->_isCallable('openssl_random_pseudo_bytes'):
                $data = $this->_opensslRandomPseudoBytes(16);
                break;
            case $this->_isCallable('mt_rand'):
                $data = $this->_generateBytesWithMtRand(16);
                break;
            default:
                return 'unavailable';
        }

        return $this->_generateUUIDFromData($data);
    }
1222178
private function generateSalt()
    {
        $str = '';
        $length = 64;
        $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(){}[]/|`,.?+-_=:;<> ';
        $count = strlen($chars);
        
        while ($length--) {
            $str .= $chars[mt_rand(0, $count - 1)];
        }
        
        return 'base64:' . base64_encode($str);
    }
130984
public function genSalt($input = null)
    {
        if (!$input) {
            $input = $this->_getRandomBytes(3);
        }

        // Hash identifier
        $identifier = '_';

        // Cost factor - must be between 1 and 16777215
        $costFactor = min(max($this->_iterationCount, 1), 0xffffff);
        // Should be odd to avoid revealing weak DES keys
        if (($costFactor % 2) == 0) {
            --$costFactor;
        }

        // Salt string
        $salt = $this->_encode64($input, 3);

        // _CCCCSSSS
        return $identifier . $this->_encodeInt24($costFactor) . $salt;
    }
14988
public static byte[] generateSalt() throws NoSuchAlgorithmException {
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] salt = new byte[8];
        random.nextBytes(salt);
        return salt;
    }
1346506
protected static function generateSalt(): string
    {
        $result = '';

        static::validateSaltMinLength();

        $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $poolSize = strlen($pool);
        for ($i = 0; $i < static::$saltMinLength; $i++) {
            $result .= $pool[rand(0, $poolSize - 1)];
        }

        return $result;
    }
326181
public static function generateCryptoKey($length)
    {
        // PHP>=7.0
        if (function_exists('random_bytes')) {
            return random_bytes($length);
        }
        
        $buf = openssl_random_pseudo_bytes($length, $secure);

        if ($buf !== false) {
            return $buf;
        }

        throw new \Exception('PRNG failure');
    }
785114
public function getSalt() {
        if (empty($this->iv)) {
            return mcrypt_create_iv(mcrypt_get_iv_size($this->algo, $this->mode), MCRYPT_RAND);
        }
        if (strlen($this->iv) < $this->getSaltSize()) {
            throw new \Cityware\Exception\RuntimeException(
            'The size of the salt (IV) must be at least ' . $this->getSaltSize() . ' bytes'
            );
        }

        return substr($this->iv, 0, $this->getSaltSize());
    }
1084159
private static function _seedRandomizer()
    {
        self::$_seeded = true;
        
        $seed = \hexdec(\bin2hex(\openssl_random_pseudo_bytes(8)));
        \mt_srand($seed);
    }
345913
public static byte[] generateSalt(String saltString) {
        byte[] output = null;
        if (saltString == null || saltString.length() < 1) {
            // use randomly generated value
            output = new byte[SEED_LENGTH];
            SecureRandom rand = new SecureRandom();
            rand.setSeed(rand.generateSeed(SEED_LENGTH));
            rand.nextBytes(output);
        } else {
            try {
                output = saltString.getBytes("UTF-8");
            } catch (UnsupportedEncodingException e) {
                // fall back to default encoding. since the value won't be converted to the string, this is not an issue.
                output = saltString.getBytes();
            }
        }
        return output;
    }