Skip to content

Instantly share code, notes, and snippets.

@NicolasCARPi
Created February 18, 2026 20:29
Show Gist options
  • Select an option

  • Save NicolasCARPi/8cab158ecbcf469d0974c101b764ba60 to your computer and use it in GitHub Desktop.

Select an option

Save NicolasCARPi/8cab158ecbcf469d0974c101b764ba60 to your computer and use it in GitHub Desktop.
<?php
// https://github.com/RobThree/TwoFactorAuth/issues/157
// install dependency with:
// docker run --rm -v $PWD:/app composer require robthree/twofactorauth
require_once './vendor/autoload.php';
use RobThree\Auth\TwoFactorAuth;
use RobThree\Auth\Providers\Qr\QRServerProvider;
$tfa = new TwoFactorAuth(new QRServerProvider(), "test issue 157", period: 60);
$secret = $tfa->createSecret();
$code = $tfa->getCode($secret);
var_dump($tfa->verifyCode($secret, $code)); // bool(true)
// run with php bug.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment