custom.php 1005 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. require_once '../vendor/autoload.php';
  3. use chillerlan\QRCode\QRCode;
  4. use chillerlan\QRCode\QROptions;
  5. use chillerlan\QRCode\Output\QRString;
  6. use chillerlan\QRCode\Output\QRStringOptions;
  7. $starttime = microtime(true);
  8. $qrOptions = new QROptions;
  9. $qrOptions->typeNumber = QRCode::TYPE_05;
  10. $qrOptions->errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_M;
  11. $qrStringOptions = new QRStringOptions;
  12. $qrStringOptions->type = QRCode::OUTPUT_STRING_TEXT;
  13. $qrStringOptions->textDark = '#';
  14. $qrStringOptions->textLight = ' ';
  15. // google authenticator
  16. // https://chart.googleapis.com/chart?chs=200x200&chld=M%7C0&cht=qr&chl=otpauth%3A%2F%2Ftotp%2Ftest%3Fsecret%3DB3JX4VCVJDVNXNZ5%26issuer%3Dchillerlan.net
  17. $qrcode = new QRCode('otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', new QRString($qrStringOptions), $qrOptions);
  18. echo '<pre>'.$qrcode->output().'</pre>';
  19. echo '<pre>'.print_r($qrcode->getRawData(), true).'</pre>';
  20. echo 'QRCode: '.round((microtime(true)-$starttime), 5).PHP_EOL;