Time-based one-time passwords (RFC 6238, over RFC 4226's HOTP): the 6 digits an authenticator app (Google Authenticator, FreeOTP, a password manager) shows for a secret, changing every 30 seconds. HMAC-SHA1, as every app reads an otpauth:// link without algorithm. No dependency: a secret is base32, as the apps take it
final class MMO\oauth\helpers\Totp
Namespace
MMO\oauth\helpers
$secret = Totp::Secret(); // 'JBSWY3DPEHPK3PXP...'
Totp::Verify($secret, $_POST['code'], $user->lastStep); // the step it matched, null for a wrong code
Check a code typed: the one of the current step, or of the step before or after (a clock a little off, a code typed as it changed), and of a step after $lastStep only, so that a code seen once open…
Check a code typed: the one of the current step, or of the step before or after (a clock a little off, a code typed as it changed), and of a step after $lastStep only, so that a code seen once opens nothing (replay)