1

I am attempting to use a set of PHP classes for encryption here: https://github.com/defuse/php-encryption

I have downloaded the PHAR file and uploaded it to my server, but it does not work. From the installation instructions, it just seems like you pass the file's path to require_once and then you can use it, but I get an error:

Fatal error: Class 'Key' not found in G:\PleskVhosts\insurancemidam.com\httpdocs\test\confirmation.php on line 4

Here is some of my PHP:

require_once('defuse-crypto.phar');
include('header.php');
$key = Key::createNewRandomKey();
echo $key->saveToAsciiSafeString();

I have tried putting it in 'header.php' with no success either.

I would really appreciate any help! Thanks

KellyM
  • 2,472
  • 6
  • 46
  • 90
  • Try the full path to the file. Make sure you meet the requirements. "This library requres no special dependencies except for PHP 5.4 or newer with the OpenSSL extensions enabled (this is the default)." – miken32 Jun 07 '16 at 17:13
  • Thanks for the input. Unfortunately, I still could not get it to work even though I have tried numerous file path combinations, OpenSSL is enabled, and I am running PHP 5.4. Thanks! – KellyM Jun 07 '16 at 17:38
  • http://stackoverflow.com/q/845021/1255289 – miken32 Jun 07 '16 at 17:40

1 Answers1

1

put the following line at the top of your script just under the require_once statement:

use \Defuse\Crypto\Key

It has to do with namespace

miken32
  • 42,008
  • 16
  • 111
  • 154
MrNWP
  • 11
  • 1