createSecret(); echo '
  • First create a secret and associate it with a user: ' . $secret . ' (keep this code private; do not share it with the user or anyone else)'; echo '
  • Next create a QR code and let the user scan it:
    '; $code = $tfa->getCode($secret); echo '
  • Next, have the user verify the code; at this time the code displayed by a 2FA-app would be: ' . $code . ' (but that changes periodically)'; echo '
  • When the code checks out, 2FA can be / is enabled; store secret with user (encrypted?) and have the user verify a code each time a new session is started.'; echo '
  • When aforementioned code (' . $code . ') was entered, the result would be: ' . (($tfa->verifyCode($secret, $code) === true) ? 'OK' : 'FAIL'); echo '
  • Make sure server-time is NTP-synced!'; ?>