src/PrivateKey.php
/**
     * Export the current private key to a new private key with a different password
     *
     * @param string $newPassPhrase If empty the new private key will be unencrypted
     * @return self
     */
Export the current private key to a new private key with a different password
@param string $newPassPhrase If empty the new private key will be unencrypted
@return self
Export the current private key to a new private key with a different password @param string $newPassPhrase If empty the new private key will be unencrypted @return self
public function changePassPhrase(string $newPassPhrase): self
    {
        $pem = $this->callOnPrivateKey(
            function ($privateKey) use ($newPassPhrase): string {
                $exportConfig = [
                    'private_key_bits' => $this->publicKey()->numberOfBits(),
                    'encrypt_key' => ('' !== $newPassPhrase), 
                ];
                if (! openssl_pkey_export($privateKey, $exported, $newPassPhrase, $exportConfig)) {
                    throw new RuntimeException('Cannot export the private KEY to change password');
                }
                return $exported;
            }
        );
        return new self($pem, $newPassPhrase);
    }
public function changePassPhrase ( string $ newPassPhrase ) : self { $ pem = $ this -> callOnPrivateKey ( function ( $ privateKey ) use ( $ newPassPhrase ) : string { $ exportConfig = [ 'private_key_bits' => $ this -> publicKey ( ) -> numberOfBits ( ) , 'encrypt_key' => ( '' !== $ newPassPhrase ) , ] ; if ( ! openssl_pkey_export ( $ privateKey , $ exported , $ newPassPhrase , $ exportConfig ) ) { throw new RuntimeException ( 'Cannot export the private KEY to change password' ) ; } return $ exported ; } ) ; return new self ( $ pem , $ newPassPhrase ) ; }
Export the current private key to a new private key with a different password
 @param string $newPassPhrase If empty the new private key will be unencrypted
 @return self
Export the current private key to a new private key with a different password @param string $newPassPhrase If empty the new private key will be unencrypted @return self
// if empty then set that the key is not encrypted