19 lines
604 B
PHP
19 lines
604 B
PHP
<?php
|
|
use ParagonIE_Sodium_Compat as SodiumCompat;
|
|
require 'vendor/autoload.php';
|
|
$randomBytes = substr(
|
|
SodiumCompat::randombytes_buf(512),
|
|
random_int(SodiumCompat::CRYPTO_GENERICHASH_BYTES, 512),
|
|
SodiumCompat::CRYPTO_GENERICHASH_BYTES_MAX
|
|
);
|
|
|
|
$rawToken = SodiumCompat::crypto_generichash(
|
|
$randomBytes,
|
|
SodiumCompat::randombytes_buf(
|
|
SodiumCompat::CRYPTO_GENERICHASH_BYTES_MAX
|
|
),
|
|
32
|
|
);
|
|
$token = SodiumCompat::bin2hex($rawToken);
|
|
|
|
print $token . PHP_EOL; |