PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found
PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found
我想在 PHP 中使用椭圆曲线密码术生成 private/public 密钥。
我用过这个库:https://github.com/simplito/elliptic-php
我的代码:
<?php
use Elliptic\EC;
// Create and initialize EC context
// (better do it once and reuse it)
$ec = new EC('secp256k1');
// Generate keys
$key = $ec->genKeyPair();
$publicKey = $key->getPublic('hex');
$privateKey = $key->getPrivate('hex');
// Print the keys to the console
echo "The address1 is {$publicKey}. \r\n";
echo "The address1 is {$privateKey}. \r\n";
但它向我显示了这个错误:
PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found in /home/istabraq/bctest/test1/keygenerator.php:6
我已经安装了composer Composer 1.6.3
来自本教程:
https://linuxize.com/post/how-to-install-and-use-composer-on-ubuntu-18-04/
然后安装sudo apt-get install php7.2-gmp
并安装了 composer require simplito/elliptic-php
最后安装了 composer require simplito/bn-php
但最后的命令行显示了这个输出:
Using version ^1.1 for simplito/bn-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
我遗漏了什么请帮忙?我搜索问题但没有教程。
尝试使用 class 包含文件,或者如果存在 vendor/autoload.php
包含它,例如:
<?php
include 'path/vendor/autoload.php'; //or 'path/file/EC.php'
use Elliptic\EC;
// Create and initialize EC context
// (better do it once and reuse it)
$ec = new EC('secp256k1');
// Generate keys
$key = $ec->genKeyPair();
$publicKey = $key->getPublic('hex');
$privateKey = $key->getPrivate('hex');
// Print the keys to the console
echo "The address1 is {$publicKey}. \r\n";
echo "The address1 is {$privateKey}. \r\n";
我想在 PHP 中使用椭圆曲线密码术生成 private/public 密钥。
我用过这个库:https://github.com/simplito/elliptic-php
我的代码:
<?php
use Elliptic\EC;
// Create and initialize EC context
// (better do it once and reuse it)
$ec = new EC('secp256k1');
// Generate keys
$key = $ec->genKeyPair();
$publicKey = $key->getPublic('hex');
$privateKey = $key->getPrivate('hex');
// Print the keys to the console
echo "The address1 is {$publicKey}. \r\n";
echo "The address1 is {$privateKey}. \r\n";
但它向我显示了这个错误:
PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found in /home/istabraq/bctest/test1/keygenerator.php:6
我已经安装了composer Composer 1.6.3
来自本教程:
https://linuxize.com/post/how-to-install-and-use-composer-on-ubuntu-18-04/
然后安装sudo apt-get install php7.2-gmp
并安装了 composer require simplito/elliptic-php
最后安装了 composer require simplito/bn-php
但最后的命令行显示了这个输出:
Using version ^1.1 for simplito/bn-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
我遗漏了什么请帮忙?我搜索问题但没有教程。
尝试使用 class 包含文件,或者如果存在 vendor/autoload.php
包含它,例如:
<?php
include 'path/vendor/autoload.php'; //or 'path/file/EC.php'
use Elliptic\EC;
// Create and initialize EC context
// (better do it once and reuse it)
$ec = new EC('secp256k1');
// Generate keys
$key = $ec->genKeyPair();
$publicKey = $key->getPublic('hex');
$privateKey = $key->getPrivate('hex');
// Print the keys to the console
echo "The address1 is {$publicKey}. \r\n";
echo "The address1 is {$privateKey}. \r\n";