Note that there are some explanatory texts on larger screens.

plurals
  1. POEncrypt message with Cryptico public key using PHP
    primarykey
    data
    text
    <p>Is it possible to generate an RSA public key from a passphrase using <a href="https://github.com/wwwtyro/cryptico" rel="nofollow">Cryptico</a>, then use PHP to encrypt a message with that public key, and decrypt it with JavaScrpt using the original passphrase?</p> <p>Cryptico seems to work great on its own, but I'm trying to use phpseclib to encrypt a message using the public key that Cryptico generated and i'm not getting an output. Even if I did, would I be able to base64 encode it and decrypt it with Cryptico?</p> <p>Using the passphase "stackoverflow rocks" with Bits set to 1024 I get this public key:</p> <p><code>XEjrqvt5K3pjM2m98ZFQOf9fObVNKPJQ9TYbo4sdNPaUO0NKdLtno8hXa292MiAmwip9JOiplmSQVEvpEnfebGNFFzqNgd4hAS6oXD6zHexVHsHpFTYxfVFQE93eHtbz0Mi7l64rnq6UOQKAB53CXVUev6RqyR6hs4oBiJRAOCs=</code></p> <p>But when I use the following code with or without the PKCS1 line, I get no output. <pre><code>$rsa = new Crypt_RSA(); $rsa-&gt;loadKey('XEjrqvt5K3pjM2m98ZFQOf9fObVNKPJQ9TYbo4sdNPaUO0NKdLtno8hXa292MiAmwip9JOiplmSQVEvpEnfebGNFFzqNgd4hAS6oXD6zHexVHsHpFTYxfVFQE93eHtbz0Mi7l64rnq6UOQKAB53CXVUev6RqyR6hs4oBiJRAOCs='); // public key $plaintext = 'tester'; $rsa-&gt;setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $ciphertext = $rsa-&gt;encrypt($plaintext); echo $ciphertext; ?&gt; </code></pre> <p>Does anyone know what i'm missing to make this work? - Or is this impossible and i'm wasting my time?</p> <p>EDIT: ------------ Code i'm using re owlstead's comment ------------- Tried with and without the PKCS1 line</p> <pre><code>&lt;?php include('Crypt/RSA.php'); $rsa = new Crypt_RSA(); $rsa-&gt;loadKey('-----BEGIN PUBLIC KEY----- XEjrqvt5K3pjM2m98ZFQOf9fObVNKPJQ9TYbo4sdNPaUO0NKdLtno8hXa292MiAmwip9JOiplmSQVEvpEnfebGNFFzqNgd4hAS6oXD6zHexVHsHpFTYxfVFQE93eHtbz0Mi7l64rnq6UOQKAB53CXVUev6RqyR6hs4oBiJRAOCs= -----END PUBLIC KEY-----'); // public key $plaintext = 'tester'; $rsa-&gt;setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $ciphertext = $rsa-&gt;encrypt($plaintext); echo $ciphertext; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload