phpseclib\Crypt\RSA\OpenSSH::savePublicKey PHP Метод

savePublicKey() статический публичный Метод

Convert a public key to the appropriate format
static public savePublicKey ( phpseclib\Math\BigInteger $n, phpseclib\Math\BigInteger $e ) : string
$n phpseclib\Math\BigInteger
$e phpseclib\Math\BigInteger
Результат string
    static function savePublicKey(BigInteger $n, BigInteger $e)
    {
        $publicExponent = $e->toBytes(true);
        $modulus = $n->toBytes(true);
        // from <http://tools.ietf.org/html/rfc4253#page-15>:
        // string    "ssh-rsa"
        // mpint     e
        // mpint     n
        $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus);
        $RSAPublicKey = 'ssh-rsa ' . Base64::encode($RSAPublicKey) . ' ' . self::$comment;
        return $RSAPublicKey;
    }