0

I'm trying to setup the NanoSalt library on XAMPP with PHP 8.1

It return to me this error:

Fatal error: Uncaught Error: Class "MikeRow\Salt\Exception" not found in C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\NanoSalt.php:28 Stack trace: #0 C:\xampp\htdocs\Peppe\index.php(3): require_once() #1 {main} thrown in C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\NanoSalt.php on line 28

That's my index.php content:

<?php
use MikeRow\Salt\NanoSalt;
require_once "vendor/mikerow/salt/src/NanoSalt.php";

$nanoSalt = new NanoSalt();
$public_key = $nanoSalt->crypto_sign_public_from_secret_key(hex2bin("781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3"));
print(strtoupper($public_key->toHex()) . PHP_EOL);

?>

How can I resolve that?

8
  • When using composer, you don't require individual files. Instead, require the automatically generated vendor/autoload.php file. Commented Dec 30, 2021 at 14:56
  • @ChrisHaas - It didn't helped, that's new error: Fatal error: Uncaught Error: Class "MikeRow\Salt\Exception" not found in C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\NanoSalt.php:28 Stack trace: #0 C:\xampp\htdocs\Peppe\vendor\composer\ClassLoader.php(571): include() #1 C:\xampp\htdocs\Peppe\vendor\composer\ClassLoader.php(428): Composer\Autoload\includeFile('C:\\xampp\\htdocs...') #2 C:\xampp\htdocs\Peppe\index.php(5): Composer\Autoload\ClassLoader->loadClass('MikeRow\\Salt\\Na...') #3 {main} thrown in C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\NanoSalt.php on line 28 Commented Dec 30, 2021 at 15:01
  • Oh, I see now. First, that code is archived, so the author is probably not maintaining it, and I wouldn't recommend using it. You will need to hack the files, the Exception class on line 28 needs a leading "\", or you can bring it into scope with a use statement. There might be other problems of a similar nature in there, too. Commented Dec 30, 2021 at 15:05
  • A new error: Fatal error: Uncaught Error: Call to undefined method MikeRow\Salt\FieldElement::rewind() in C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\FieldElement.php:21 Stack trace: #0 C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\NanoSalt.php(300): MikeRow\Salt\FieldElement->toString() #1 C:\xampp\htdocs\Peppe\index.php(6): MikeRow\Salt\NanoSalt->crypto_sign_public_from_secret_key(Object(MikeRow\Salt\FieldElement)) #2 {main} thrown in C:\xampp\htdocs\Peppe\vendor\mikerow\salt\src\FieldElement.php on line 21 Commented Dec 30, 2021 at 15:08
  • 1
    I'm sorry, the package you are trying to use appears to have several bugs. I would recommend not using it, or contact the author. Fixing each one here doesn't seem useful. Commented Dec 30, 2021 at 15:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.