public function encrypt($contents, $certificate)
    {
        $x509 = new X509();
        $x509->loadX509($certificate);

        $rsa = new RSA();
        $rsa->loadKey($x509->getPublicKey());

        $rsa->setSignatureMode(RSA::ENCRYPTION_PKCS1);

        return $rsa->encrypt($contents);
    }
public function encrypt($contents, $certificate)
    {
        $x509 = new X509();
        $x509->loadX509($certificate);

        $rsa = new RSA();
        $rsa->loadKey($x509->getPublicKey());

        $rsa->setSignatureMode(RSA::ENCRYPTION_PKCS1);

        return $rsa->encrypt($contents);
    }
public function encrypt ( $ contents , $ certificate ) { $ x509 = new X509 ( ) ; $ x509 -> loadX509 ( $ certificate ) ; $ rsa = new RSA ( ) ; $ rsa -> loadKey ( $ x509 -> getPublicKey ( ) ) ; $ rsa -> setSignatureMode ( RSA :: ENCRYPTION_PKCS1 ) ; return $ rsa -> encrypt ( $ contents ) ; }
Encrypt contents with the recipient's X.509 certificate

@param string $contents
@param string $certificate

@return string
Encrypt contents with the recipient s X . 509 certificate