mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
32 lines
520 B
PHP
32 lines
520 B
PHP
#!/usr/bin/php
|
|
<?php
|
|
/*
|
|
* Usage: generate.php [key]
|
|
*
|
|
* If no key is provided as an arg, the script will ask for it.
|
|
*
|
|
*/
|
|
|
|
include __DIR__.'/vendor/autoload.php';
|
|
|
|
use lfkeitel\phptotp\Totp;
|
|
use lfkeitel\phptotp\Base32;
|
|
|
|
$key = '';
|
|
|
|
if ($argc == 2) {
|
|
$key = $argv[1];
|
|
} else {
|
|
echo "Enter secret key: ";
|
|
$key = trim(fgets(STDIN));
|
|
|
|
if ($key == '') {
|
|
echo "No key provided\n";
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
$key = Base32::decode($key);
|
|
|
|
echo "Token: " . (new Totp())->GenerateToken($key) . "\n";
|