src/Algorithms.php
public static function sortAlgorithms($a, $b)
    {
        static $preferences = array(
            // DH (KEX)
            'curve25519-sha256@libssh.org',
            'ecdh-sha2-nistp256',
            'ecdh-sha2-nistp384',
            'ecdh-sha2-nistp521',
            'diffie-hellman-group-exchange-sha256',
            'diffie-hellman-group-exchange-sha1',
            'diffie-hellman-group14-sha1',
            'diffie-hellman-group1-sha1',

            // PublicKey
            'ecdsa-sha2-nistp256-cert-v01@openssh.com',
            'ecdsa-sha2-nistp384-cert-v01@openssh.com',
            'ecdsa-sha2-nistp521-cert-v01@openssh.com',
            'ecdsa-sha2-nistp256',
            'ecdsa-sha2-nistp384',
            'ecdsa-sha2-nistp521',
            'ssh-ed25519-cert-v01@openssh.com',
            'ssh-rsa-cert-v01@openssh.com',
            'ssh-dss-cert-v01@openssh.com',
            'ssh-rsa-cert-v00@openssh.com',
            'ssh-dss-cert-v00@openssh.com',
            'ssh-ed25519',
            'ssh-rsa',
            'ssh-dss',

            // Encryption
            'aes128-ctr',
            'aes192-ctr',
            'aes256-ctr',
            'aes128-gcm@openssh.com',
            'aes256-gcm@openssh.com',
            'chacha20-poly1305@openssh.com',
            'arcfour256',
            'arcfour128',
            'aes128-cbc',
            '3des-cbc',
            'blowfish-cbc',
            'cast128-cbc',
            'aes192-cbc',
            'aes256-cbc',
            'arcfour',
            'rijndael-cbc@lysator.liu.se',

            // MAC
            'umac-64-etm@openssh.com',
            'umac-128-etm@openssh.com',
            'hmac-sha2-256-etm@openssh.com',
            'hmac-sha2-512-etm@openssh.com',
            'hmac-sha1-etm@openssh.com',
            'umac-64@openssh.com',
            'umac-128@openssh.com',
            'hmac-sha2-256',
            'hmac-sha2-512',
            'hmac-sha1',
            'hmac-md5-etm@openssh.com',
            'hmac-ripemd160-etm@openssh.com',
            'hmac-sha1-96-etm@openssh.com',
            'hmac-md5-96-etm@openssh.com',
            'hmac-md5',
            'hmac-ripemd160',
            'hmac-ripemd160@openssh.com',
            'hmac-sha1-96',
            'hmac-md5-96',

            // Compression
            'none',
            'zlib@openssh.com',
            'zlib',
        );

        $iA = array_search($a, $preferences, true);
        $iB = array_search($b, $preferences, true);
        if ($iA === false) {
            return ($iB === false ? 0 : 1);
        }
        if ($iB === false) {
            return -1;
        }
        return ($iA - $iB);
    }
public static function sortAlgorithms($a, $b)
    {
        static $preferences = array(
            // DH (KEX)
            'curve25519-sha256@libssh.org',
            'ecdh-sha2-nistp256',
            'ecdh-sha2-nistp384',
            'ecdh-sha2-nistp521',
            'diffie-hellman-group-exchange-sha256',
            'diffie-hellman-group-exchange-sha1',
            'diffie-hellman-group14-sha1',
            'diffie-hellman-group1-sha1',

            // PublicKey
            'ecdsa-sha2-nistp256-cert-v01@openssh.com',
            'ecdsa-sha2-nistp384-cert-v01@openssh.com',
            'ecdsa-sha2-nistp521-cert-v01@openssh.com',
            'ecdsa-sha2-nistp256',
            'ecdsa-sha2-nistp384',
            'ecdsa-sha2-nistp521',
            'ssh-ed25519-cert-v01@openssh.com',
            'ssh-rsa-cert-v01@openssh.com',
            'ssh-dss-cert-v01@openssh.com',
            'ssh-rsa-cert-v00@openssh.com',
            'ssh-dss-cert-v00@openssh.com',
            'ssh-ed25519',
            'ssh-rsa',
            'ssh-dss',

            // Encryption
            'aes128-ctr',
            'aes192-ctr',
            'aes256-ctr',
            'aes128-gcm@openssh.com',
            'aes256-gcm@openssh.com',
            'chacha20-poly1305@openssh.com',
            'arcfour256',
            'arcfour128',
            'aes128-cbc',
            '3des-cbc',
            'blowfish-cbc',
            'cast128-cbc',
            'aes192-cbc',
            'aes256-cbc',
            'arcfour',
            'rijndael-cbc@lysator.liu.se',

            // MAC
            'umac-64-etm@openssh.com',
            'umac-128-etm@openssh.com',
            'hmac-sha2-256-etm@openssh.com',
            'hmac-sha2-512-etm@openssh.com',
            'hmac-sha1-etm@openssh.com',
            'umac-64@openssh.com',
            'umac-128@openssh.com',
            'hmac-sha2-256',
            'hmac-sha2-512',
            'hmac-sha1',
            'hmac-md5-etm@openssh.com',
            'hmac-ripemd160-etm@openssh.com',
            'hmac-sha1-96-etm@openssh.com',
            'hmac-md5-96-etm@openssh.com',
            'hmac-md5',
            'hmac-ripemd160',
            'hmac-ripemd160@openssh.com',
            'hmac-sha1-96',
            'hmac-md5-96',

            // Compression
            'none',
            'zlib@openssh.com',
            'zlib',
        );

        $iA = array_search($a, $preferences, true);
        $iB = array_search($b, $preferences, true);
        if ($iA === false) {
            return ($iB === false ? 0 : 1);
        }
        if ($iB === false) {
            return -1;
        }
        return ($iA - $iB);
    }
public static function sortAlgorithms ( $ a , $ b ) { static $ preferences = array ( // DH (KEX) 'curve25519-sha256@libssh.org' , 'ecdh-sha2-nistp256' , 'ecdh-sha2-nistp384' , 'ecdh-sha2-nistp521' , 'diffie-hellman-group-exchange-sha256' , 'diffie-hellman-group-exchange-sha1' , 'diffie-hellman-group14-sha1' , 'diffie-hellman-group1-sha1' , // PublicKey 'ecdsa-sha2-nistp256-cert-v01@openssh.com' , 'ecdsa-sha2-nistp384-cert-v01@openssh.com' , 'ecdsa-sha2-nistp521-cert-v01@openssh.com' , 'ecdsa-sha2-nistp256' , 'ecdsa-sha2-nistp384' , 'ecdsa-sha2-nistp521' , 'ssh-ed25519-cert-v01@openssh.com' , 'ssh-rsa-cert-v01@openssh.com' , 'ssh-dss-cert-v01@openssh.com' , 'ssh-rsa-cert-v00@openssh.com' , 'ssh-dss-cert-v00@openssh.com' , 'ssh-ed25519' , 'ssh-rsa' , 'ssh-dss' , // Encryption 'aes128-ctr' , 'aes192-ctr' , 'aes256-ctr' , 'aes128-gcm@openssh.com' , 'aes256-gcm@openssh.com' , 'chacha20-poly1305@openssh.com' , 'arcfour256' , 'arcfour128' , 'aes128-cbc' , '3des-cbc' , 'blowfish-cbc' , 'cast128-cbc' , 'aes192-cbc' , 'aes256-cbc' , 'arcfour' , 'rijndael-cbc@lysator.liu.se' , // MAC 'umac-64-etm@openssh.com' , 'umac-128-etm@openssh.com' , 'hmac-sha2-256-etm@openssh.com' , 'hmac-sha2-512-etm@openssh.com' , 'hmac-sha1-etm@openssh.com' , 'umac-64@openssh.com' , 'umac-128@openssh.com' , 'hmac-sha2-256' , 'hmac-sha2-512' , 'hmac-sha1' , 'hmac-md5-etm@openssh.com' , 'hmac-ripemd160-etm@openssh.com' , 'hmac-sha1-96-etm@openssh.com' , 'hmac-md5-96-etm@openssh.com' , 'hmac-md5' , 'hmac-ripemd160' , 'hmac-ripemd160@openssh.com' , 'hmac-sha1-96' , 'hmac-md5-96' , // Compression 'none' , 'zlib@openssh.com' , 'zlib' , ) ; $ iA = array_search ( $ a , $ preferences , true ) ; $ iB = array_search ( $ b , $ preferences , true ) ; if ( $ iA === false ) { return ( $ iB === false ? 0 : 1 ) ; } if ( $ iB === false ) { return - 1 ; } return ( $ iA - $ iB ) ; }
Sort algorithms based on preferences.

\param string $a
Name of the first algorithm.

\param string $b
Name of the second algorithm.

\retval int
An integer that is less than zero if the first algorithm
should be preferred, equal to zero if both algorithms have
the same preference and greater than zero when the second
algorithm should be preferred.
Sort algorithms based on preferences .