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);
    }