0

When tring to use/import the phpseclib RSA class unable to find out the class, could you help me please.

`

require "/vendor/autoload.php";
use phpseclib\Crypt\RSA;

// INPUT DATA
$privkey = "...";   // I used a RSA private key in PEM format, generated by openssl, but phpseclib supports many formats...
$mydata = "...";    // I generated some binary bytes here...

// SIGNING
$rsa = new RSA();
if ($rsa->loadKey($privkey) != TRUE) {
    echo "Error loading private key";
    return;
}
$rsa->setHash("sha512");
$rsa->setMGFHash("sha512"); // This NEEDS to be set, or the default will be used
$rsa->setSignatureMode(RSA::SIGNATURE_PSS); // This doesn't need to be set, as it is already the default value
$signatureBytes = $rsa->sign($mydata);

`

Ebsa Teklu
  • 29
  • 2
  • Can you post your composer.json? In particular, I'm wondering if you're using phpseclib 3.0. Like you're using the 2.0 API but if you're using phpseclib 3.0 then you need to be using a different API. – neubert Jan 05 '23 at 14:00

0 Answers0