-1

I want to do JWE in php. I've installed gree/jose library and also phpseclib via composer. But, why I'm keep getting error below?

Fatal error: Class 'phpseclib\Crypt\Random' not found in /export/vhost/onlinepayment.com.my/htdocs/NBepay/vendor/gree/jose/src/JOSE/JWE.php on line 106

below are the libraries that i've installed.

  1. composer require gree/jose
  2. composer require phpseclib/phpseclib:~3.0

Already included autoload and the JOSE.

include_once $FIXPATH."vendor/autoload.php";
use \JOSE\JWE;

what should I do?

neubert
  • 15,947
  • 24
  • 120
  • 212

1 Answers1

2

gree/jose requires phpseclib/phpseclib:~2.0 - not 3.0. If you want to use 3.0 and 2.0 side by side you'll need to require phpseclib/phpseclib2_compat:~1.0 in addition to phpseclib/phpseclib:~3.0.

This is relevant because phpseclib v3 has a new namespace - phpseclib3\Crypt\Random instead of phpseclib\Crypt\Random. The name space change is what makes phpseclib/phpseclib2_compat:~1.0 possible

neubert
  • 15,947
  • 24
  • 120
  • 212