public function getFingerprintByPublicKey($publicKeyString)
    {
        $keyResource = openssl_pkey_get_public($publicKeyString);
        $keyDetails = openssl_pkey_get_details($keyResource);
        $modulus = $this->sshConvertMpint($keyDetails['rsa']['n']);
        $publicExponent = $this->sshConvertMpint($keyDetails['rsa']['e']);

        $rsaPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus);

        return md5($rsaPublicKey);
    }
public function getFingerprintByPublicKey($publicKeyString)
    {
        $keyResource = openssl_pkey_get_public($publicKeyString);
        $keyDetails = openssl_pkey_get_details($keyResource);
        $modulus = $this->sshConvertMpint($keyDetails['rsa']['n']);
        $publicExponent = $this->sshConvertMpint($keyDetails['rsa']['e']);

        $rsaPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus);

        return md5($rsaPublicKey);
    }
public function getFingerprintByPublicKey ( $ publicKeyString ) { $ keyResource = openssl_pkey_get_public ( $ publicKeyString ) ; $ keyDetails = openssl_pkey_get_details ( $ keyResource ) ; $ modulus = $ this -> sshConvertMpint ( $ keyDetails [ 'rsa' ] [ 'n' ] ) ; $ publicExponent = $ this -> sshConvertMpint ( $ keyDetails [ 'rsa' ] [ 'e' ] ) ; $ rsaPublicKey = pack ( 'Na*Na*Na*' , strlen ( 'ssh-rsa' ) , 'ssh-rsa' , strlen ( $ publicExponent ) , $ publicExponent , strlen ( $ modulus ) , $ modulus ) ; return md5 ( $ rsaPublicKey ) ; }
Generate an OpenSSH fingerprint for a RSA public key

See <http://tools.ietf.org/html/rfc4253#page-15> for reference of OpenSSH
"ssh-rsa" key format. The fingerprint is obtained by applying an MD5
hash on the raw public key bytes.

If you have a PEM encoded private key, you can generate the same fingerprint
using this:

ssh-keygen -yf my-key.pem > my-key.pub
ssh-keygen -lf my-key.pub

@param string $publicKeyString RSA public key, PKCS1 encoded
@return string The public key fingerprint
Generate an OpenSSH fingerprint for a RSA public key