mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 22:20:29 +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";
|