authenticator.php 624 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. *
  4. * @filesource authenticator.php
  5. * @created 10.11.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. require_once '../vendor/autoload.php';
  11. use chillerlan\{
  12. GoogleAuth\Authenticator,
  13. QRCode\QRCode,
  14. QRCode\Output\QRMarkup
  15. };
  16. $authenticator = new Authenticator;
  17. $secret = $authenticator->createSecret(); // -> userdata
  18. $data = $authenticator->getUri($secret, 'label', 'example.com');
  19. // markup - svg
  20. echo '<!DOCTYPE html><html><head><meta charset="UTF-8"/></head><body><div>'.(new QRCode($data, new QRMarkup))->output().'</div></body>';