custom.php 871 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. require_once '../vendor/autoload.php';
  3. use chillerlan\QRCode\QRCode;
  4. use chillerlan\QRCode\QRConst;
  5. use chillerlan\QRCode\QROptions;
  6. $starttime = microtime(true);
  7. $qrOptions = new QROptions;
  8. $qrOptions->typeNumber = QRConst::TYPE_05;
  9. $qrOptions->errorCorrectLevel = QRConst::ERROR_CORRECT_LEVEL_M;
  10. // google authenticator
  11. // https://chart.googleapis.com/chart?chs=200x200&chld=M%7C0&cht=qr&chl=otpauth%3A%2F%2Ftotp%2Ftest%3Fsecret%3DB3JX4VCVJDVNXNZ5%26issuer%3Dchillerlan.net
  12. $qrcode = new QRCode;
  13. $qrcode->setOptions($qrOptions, 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net');
  14. $qrcode->getRawData();
  15. for($row = 0; $row < $qrcode->pixelCount; $row++){
  16. for($col = 0; $col < $qrcode->pixelCount; $col++){
  17. echo $qrcode->matrix[$row][$col] ? '*' : ' ';
  18. }
  19. echo PHP_EOL;
  20. }
  21. echo 'QRCode: '.round((microtime(true)-$starttime), 5).PHP_EOL;