custom.php 1.1 KB

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