custom.php 1.0 KB

1234567891011121314151617181920212223242526272829
  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. var_dump($qrcode->output());
  19. $qrcode->setData('otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=buildwars.net', $qrOptions);
  20. var_dump($qrcode->getRawData());
  21. echo 'QRCode: '.round((microtime(true)-$starttime), 5).PHP_EOL;