KellyM
KellyM

Reputation: 2522

Difficulty Loading PHAR Package in PHP

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

Upvotes: 1

Views: 239

Answers (1)

MrNWP
MrNWP

Reputation: 11

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

Upvotes: 1

Related Questions