1. Go to this page and download the library: Download secudoc/php-liboqs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
secudoc / php-liboqs example snippets
use OQS\KEM;
// Pick an algorithm supported by your liboqs build:
$alg = defined('OQS\\KEM::ALG_ML_KEM_768') ? OQS\KEM::ALG_ML_KEM_768 : OQS\KEM::ALG_KYBER768;
[$pk, $sk] = KEM::keypair($alg);
[$ct, $ss1] = KEM::encapsulate($alg, $pk);
$ss2 = KEM::decapsulate($alg, $ct, $sk);
assert(hash_equals($ss1, $ss2));
// If you need text-safe values:
echo base64_encode($ct), "\n", base64_encode($ss1), "\n";