Is it possible to generate an RSA public key from a passphrase using Cryptico, then use PHP to encrypt a message with that public key, and decrypt it with JavaScrpt using the original passphrase?
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?
Using the passphase "stackoverflow rocks" with Bits set to 1024 I get this public key:
XEjrqvt5K3pjM2m98ZFQOf9fObVNKPJQ9TYbo4sdNPaUO0NKdLtno8hXa292MiAmwip9JOiplmSQVEvpEnfebGNFFzqNgd4hAS6oXD6zHexVHsHpFTYxfVFQE93eHtbz0Mi7l64rnq6UOQKAB53CXVUev6RqyR6hs4oBiJRAOCs=
But when I use the following code with or without the PKCS1 line, I get no output.
$rsa = new Crypt_RSA();
$rsa->loadKey('XEjrqvt5K3pjM2m98ZFQOf9fObVNKPJQ9TYbo4sdNPaUO0NKdLtno8hXa292MiAmwip9JOiplmSQVEvpEnfebGNFFzqNgd4hAS6oXD6zHexVHsHpFTYxfVFQE93eHtbz0Mi7l64rnq6UOQKAB53CXVUev6RqyR6hs4oBiJRAOCs='); // public key
$plaintext = 'tester';
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
$ciphertext = $rsa->encrypt($plaintext);
echo $ciphertext;
?>
Does anyone know what i'm missing to make this work? - Or is this impossible and i'm wasting my time?
EDIT: ------------ Code i'm using re owlstead's comment ------------- Tried with and without the PKCS1 line
<?php
include('Crypt/RSA.php');
$rsa = new Crypt_RSA();
$rsa->loadKey('-----BEGIN PUBLIC KEY-----
XEjrqvt5K3pjM2m98ZFQOf9fObVNKPJQ9TYbo4sdNPaUO0NKdLtno8hXa292MiAmwip9JOiplmSQVEvpEnfebGNFFzqNgd4hAS6oXD6zHexVHsHpFTYxfVFQE93eHtbz0Mi7l64rnq6UOQKAB53CXVUev6RqyR6hs4oBiJRAOCs=
-----END PUBLIC KEY-----'); // public key
$plaintext = 'tester';
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
$ciphertext = $rsa->encrypt($plaintext);
echo $ciphertext;
?>