public function generateSalt()
    {
        // The length of salt to generate
        $raw_salt_len = 16;
        // The length required in the final serialization
        $required_salt_len = 22;

        $buffer = function_exists('random_bytes') ? random_bytes($raw_salt_len) :
            mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM);
        $salt = str_replace('+', '.', base64_encode($buffer));
        $salt = substr($salt, 0, $required_salt_len);

        return $salt;
    }
public function generateSalt()
    {
        // The length of salt to generate
        $raw_salt_len = 16;
        // The length required in the final serialization
        $required_salt_len = 22;

        $buffer = function_exists('random_bytes') ? random_bytes($raw_salt_len) :
            mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM);
        $salt = str_replace('+', '.', base64_encode($buffer));
        $salt = substr($salt, 0, $required_salt_len);

        return $salt;
    }
public function generateSalt ( ) { // The length of salt to generate $ raw_salt_len = 16 ; // The length required in the final serialization $ required_salt_len = 22 ; $ buffer = function_exists ( 'random_bytes' ) ? random_bytes ( $ raw_salt_len ) : mcrypt_create_iv ( $ raw_salt_len , MCRYPT_DEV_URANDOM ) ; $ salt = str_replace ( '+' , '.' , base64_encode ( $ buffer ) ) ; $ salt = substr ( $ salt , 0 , $ required_salt_len ) ; return $ salt ; }
Generate a 22 bytes salt string

@return string
Generate a 22 bytes salt string