phpseclib\Crypt\RSA\XML::savePrivateKey PHP Метод

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

Convert a private key to the appropriate format.
static public savePrivateKey ( phpseclib\Math\BigInteger $n, phpseclib\Math\BigInteger $e, phpseclib\Math\BigInteger $d, array $primes, array $exponents, array $coefficients, string $password = '' ) : string
$n phpseclib\Math\BigInteger
$e phpseclib\Math\BigInteger
$d phpseclib\Math\BigInteger
$primes array
$exponents array
$coefficients array
$password string optional
Результат string
    static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '')
    {
        if (count($primes) != 2) {
            return false;
        }
        return "<RSAKeyValue>\r\n" . '  <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . '  <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . '  <P>' . Base64::encode($primes[1]->toBytes()) . "</P>\r\n" . '  <Q>' . Base64::encode($primes[2]->toBytes()) . "</Q>\r\n" . '  <DP>' . Base64::encode($exponents[1]->toBytes()) . "</DP>\r\n" . '  <DQ>' . Base64::encode($exponents[2]->toBytes()) . "</DQ>\r\n" . '  <InverseQ>' . Base64::encode($coefficients[2]->toBytes()) . "</InverseQ>\r\n" . '  <D>' . Base64::encode($d->toBytes()) . "</D>\r\n" . '</RSAKeyValue>';
    }