Simple php class for generating public key and one-time password (TOTP) for two factor authentication
require("class.tfa.php"); $tfa = new tfa();
Get public key:
$pubkey = $tfa->getPubKey(); print $pubkey; // Example: RADV RKNM KOV3 Q22A
Store public key on the server with the user account and use it in TOTP generators like Google Authenticator or Pebble's QuickAuth.
Generate TOTP - time-based one-time password:
$pubkey = 'RADV RKNM KOV3 Q22A'; // Saved or given public key $otp = $tfa->getOtp($pubkey); print $otp; // Example: 194074
Use it to compare with TOTP generated on the other device.