custom.php 774 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. require_once '../vendor/autoload.php';
  3. use chillerlan\QRCode\QRCode;
  4. use chillerlan\QRCode\QRConst;
  5. $starttime = microtime(true);
  6. $qrcode = (new QRCode)
  7. ->setErrorCorrectLevel(QRConst::ERROR_CORRECT_LEVEL_M)
  8. ->setQRType(QRConst::TYPE_05)
  9. ;
  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
  13. ->setData('otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net')
  14. ->getRawData()
  15. ;
  16. for($row = 0; $row < $qrcode->pixelCount; $row++){
  17. for($col = 0; $col < $qrcode->pixelCount; $col++){
  18. echo $qrcode->matrix[$row][$col] ? '*' : ' ';
  19. }
  20. echo PHP_EOL;
  21. }
  22. echo 'QRCode: '.round((microtime(true)-$starttime), 5).PHP_EOL;