secret.php 590 B

12345678910111213141516
  1. <?php
  2. session_start();
  3. if ((isset($_SESSION['userContext']) === False) && (php_sapi_name() !== 'cli')) exit;
  4. require_once '/usr/local/hestia/web/inc/2fa/loader.php';
  5. Loader::register('./','RobThree\\Auth');
  6. use \RobThree\Auth\TwoFactorAuth;
  7. $tfa = new TwoFactorAuth('Hestia Control Panel');
  8. $secret = $tfa->createSecret(160); // Though the default is an 80 bits secret (for backwards compatibility reasons) we recommend creating 160+ bits secrets (see RFC 4226 - Algorithm Requirements)
  9. $qrcode = $tfa->getQRCodeImageAsDataUri(gethostname(), $secret);
  10. echo $secret . "-" . $qrcode;